Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparing dates (again)

Status
Not open for further replies.

emozley

Technical User
Jan 14, 2003
769
GB
I have a table called Bulletins which has a column called Posted. Posted is Date/Time and is set to store this in General Format eg 18/07/2005 19:18:37

I am trying to execute a query on it to pull all records where the date and time the bulletin was posted was in the future of another time which is also stored in General Format.

SELECT *
FROM Bulletins
WHERE Posted > #7/18/2005 19:11:27#;

does not return a row even though there is a record in the Bulletins table with the value 18/07/2005 19:18:21

I had to change the way the SQL statement was built in ASP as it is dd/mm/yyyy. However it is basically the same day but 7 minutes ahead. Any ideas why it's not returning the row?

cheers

Ed
 
oh oh...i see something wrong here...

which is the month and which is the day???

#7/18/2005 19:11:27#;

18/07/2005 19:18:21


if i assume mm/dd then second one is invalid

if i assume dd/mm then first one is invalid...

-DNG
 
or try something like this to keep everything in one format...

SELECT *
FROM Bulletins
WHERE Convert(varchar(20),Posted,113) > Convert(varchar(20),#7/18/2005 19:11:27#,113);

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top