954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

find a date with in dates in Database

hey,
i am developing a booking system and i want to check whether user check in dates are within booked dates.

for an example.

user wants to book 12/03 to 14/03,but some body has already booked 10/03 to 15/03.
For this scenario, we just cant check for 2 days,what i want to check is,the user asked dates are within another booked dates.
i want to do this in linq query.

hope you understand.

help needed asap,
thanks in advance.

drax12
Newbie Poster
7 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

Hi,

Check this..

StringBuilder strQ = new StringBuilder();
                strQ.Append("SELECT VALUE T FROM MyTable AS T WHERE T.ID > 0");
   if (FromDate != null)
                    strQ.Append(string.Format(" AND T.FromDate >= DATETIME'{0}'", FromDate.ToString("yyyy-MM-dd HH:mm:ss")));

                if (ToDate != null)
                    strQ.Append(string.Format(" AND T.ToDate <= DATETIME'{0}'", ToDate.ToString("yyyy-MM-dd HH:mm:ss")));
db.CreateQuery<MyTable>(strQ.ToString());


Hope this helps..

Please revert for any queries..

Regards,

Sravanthi Chepooru

Sravanthi Ch
Newbie Poster
19 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
 

help the google to search that coding

zmeditation1
Newbie Poster
10 posts since Jun 2011
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: