Compare Two Dates in Between SQL Query Using DateTimePicker Calender Asp.Net C#
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Manoj BhoirPosted May 9, 2015, 10:57 AM
Your question is not clear. If you simply want to compare two date then you can do this in C# code there is no need of SQL Query.
Use DateTime.Compare(Date1, Date2)
DateTime date1 = new DateTime(2009, 8, 1, 0, 0, 0);
DateTime date2 = new DateTime(2009, 8, 1, 12, 0, 0);
int result = DateTime.Compare(date1, date2);
Fore more details check this link :
https://msdn.microsoft.com/en-us/library/system.datetime.compare%28v=vs.110%29.aspx
If you want to Select Data from table with specific date range you can use BETWEEN.
Check this sample query :
Select * From TableName Where DateColumnName BETWEEN 'YYYY-MM-DD' AND 'YYYY-MM-DD'
Here instead of YYYY-MM-DD pass your Datepicker values in specified format.
I hope this will help you.