Why does this datetime between not work?
Posted on 2005-04-30
What am I missing here? My sp is supposed to return only the records from the table where today's date (represented by GetDate()) is between the [PhaseStartDate] and [PhaseEndDate].
Here's the SQL I'm using:
SELECT PhaseID,PhaseStartDate,PhaseEndsDate FROM tb_phases
WHERE GetDate() BETWEEN PhaseStartDate AND PhaseEndsDate
Looks simple enough, but it doesn't appear to be doing any 'BETWEEN' stuff at all.
Dates in my table are in the format 103 (dd/mm/yyyy) but I can easily convert these to UTC if it's wiser?
Sample table data:
1,#29/04/2005 10:00:00#,#10/05/2005 23:00:00#
2,#20/04/2005 10:00:00#,#10/05/2005 23:00:00#
*** PLEASE NOTE: THE TIME IS IMPORTANT! ***
When I run this query, it returns both phases, even though today is 30/04/2005.