how we can get date in between in asp.net
we want to know how we can get date in between means if posting date is 09/04/2014 and exam date is 09/08/2014 so how we can use between keyword in two dates in asp.net
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.
VulpesPosted Apr 2, 2014, 5:53 AM
public static bool IsBetween(DateTime start, DateTime end, DateTime test)
{
if (test >= start && test <= end) return true;
return false;
}
For example:
DateTime start = new DateTime(2014, 1, 1);
DateTime end = new DateTime(2014, 5, 1);
bool isBetween = IsBetween(start, end, DateTime.Today);
Response.Write(isBetween.ToString()); // True
Abhay ShankerPosted Apr 2, 2014, 5:25 AM
dt1=09/04/2014
dt2=09/08/2014
if yes then at first you need to find the days between dates as below
(dt2-dt1).TotalDays (say 4)
then for getting a date add days to date
dt1.AddDays (1)
Note:-need to add a condition which would check here that added date must be less than difference of two dates
sudheer kumarPosted Apr 2, 2014, 2:32 AM
Sivaraman DhamodaranPosted Apr 2, 2014, 2:16 AM
Are asking how do we use that in SQL Queries? Please elaborate your question