|
-
Aug 9th, 2007, 07:07 PM
#1
Thread Starter
Hyperactive Member
in between date
hello!
i have these data:
date item
08/10/2007 07:34 AM data1
08/10/2007 07:35 AM data2
08/10/2007 07:36 AM data2
08/10/2007 09:01 AM data3
how would i find the data in date between 08/10/2007 07:33 AM to 08/10/2007 07:37 AM?
i try this but it will find all including the 09:01 AM
Code:
if (DateTime.Compare(DateTime.Now.AddMinutes(-20),DateTime.Now)<0)
*****************
VB6,PHP,VS 2005
-
Aug 9th, 2007, 08:44 PM
#2
Re: in between date
Unless I'm misunderstanding the question, I'm not sure what that last line has to do with finding the DateTimes in between your start and stop. You could just put your DateTimes in a list and just loop through it and check if each one is between your start and stop DateTimes.
Assuming your have your data in a list called times and you've created a start and stop DateTime.
c# Code:
foreach (DateTime dt in times)
{
if (dt > startTime && dt < stopTime)
{
MessageBox.Show(dt.ToString());
}
}
-
Aug 9th, 2007, 09:48 PM
#3
Thread Starter
Hyperactive Member
Re: in between date
if (Convert.ToDateTime(dateValue) > DateTime.Now.AddMinutes(-20) && Convert.ToDateTime(dateValue) < DateTime.Now)
{
//add to the datagrid and
//save to the database
}
tnx you gave me an idea how to solve the problem...
*****************
VB6,PHP,VS 2005
-
Aug 10th, 2007, 06:48 AM
#4
Re: in between date
Are you querying a database for the infor? If so you would use a between construct in the SQL statement (or a > < constraint) in the WHERE cluase.
Sometimes the Programmer
Sometimes the DBA
Mazz1
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|