Thursday, February 16, 2012

asp.net SQL query between given two time

I have asp.net applicatin with SQL database communicating. in database I have date field and time field. Now I wan to do SQL query which can pull informatin on particular date between given start time to given end time

Can some one show me sample SQL query so I can pull informatin on particular day between two times

thank you

maxmax

http://sqljunkies.com/HowTo/6676BEAE-1967-402D-9578-9A1C7FD826E5.scuk

|||

select *
from sometable
where datefield between '11/2/07' and '11/15/07'

returns all records from 12:00:00 AM on 11/2/07 (that is, just after midnight of 11/1) through and including midnight of 11/15/07

You can add time values very easily:

select *
from sometable
where datefield between '2007-11-1613:30:31.497' and '2007-11-1613:31:05.670'

No comments:

Post a Comment