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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sorting for current date in sql query 1

Status
Not open for further replies.

brad10

Technical User
Jun 5, 2001
33
GB
This works on my published asp page;

"SELECT a, b, c, d FROM newtbl WHERE c = '14/12/2001'"

This doesn't;

"SELECT a, b, c, d FROM newtbl WHERE c = date()"

Does anyone know why?

 
Thanks but that doesn't work either.

The WHERE c = date() filter works when tested in Ultradev but not when the page is published.

If you change the WHERE c = date() to WHERE c ='14/12/2001' it works both in ultradev and when published??????

Any other suggestions?
 
ok. what type of database are you using? cos getdate() is a nice Access and SQL Server thing, so that should work. Also, I noticed that you use single quotes around the hard coded date - surely if you're accessing a field of type datetime, then you'd need to surround it with #'s?
Or am I so far off the mark that you can't even see me?
:eek:)
Another possibility is that getdate() returns a UK date format?
 
ChainsawJoe

Thanks - You are bang on the mark - I'm so dumb - I should've realised that because it was working with the single quotes then the field couldn't have been a date/time field - so I checked the database and whoever created it set it as a text field. It's working fine now. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top