In Table, Time and date fields are two separate fields. I need to make a query something like this give all records where date and time <= givenDateTime. How do i do that please?
EDIT
My query:-
select DateField, TimeField from Table1 where DateField <= '07/26/2009' and TimeField <= '16:26:20'
Result is:-
2008-04-22 00:00:00.000 1899-12-30 23:59:58.000
2009-04-15 00:00:00.000 1899-12-30 23:59:56.000
2006-06-06 00:00:00.000 1899-12-30 23:59:53.000
See the Time above in results. Its wrong
Break up the
@givenDateTimeto the date component and the time component and useANDto build up theWHEREclause:Date conversion taken from here.
Time conversion taken from here.
Note that the
@givenTimewill have a date of01 Jan 1900(plus the time), so be sure that your where clause takes that into account.