Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 asp sql hope this is the right place to ask

Author  Topic 

nobby
Yak Posting Veteran

58 Posts

Posted - 2008-09-10 : 11:29:03
Hi
I have this code in my asp page

Recordset1_cmd.CommandText = "SELECT * FROM tblOrders WHERE DateRedeemed = #" & Date() & "#"

it should return anything with this date 10/09/2008 dd-mm-yyyy but it doesn't if i change one of the databse records to 09/10/2008 then it returns that record . I have checked the machines local settings etc etc and all are set to the uk with the date format dd/mm/yyyy.
I haven't a clue how i get round this problem.
And i apologise in advance if this is the wrong forum to ask this question in

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-10 : 11:38:31
Access uses # as date delimeters. SQL Server uses single quotes.
Recordset1_cmd.CommandText = "SELECT * FROM tblOrders WHERE DateRedeemed = '" & Date() & "'"




E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-10 : 11:39:43
Is DateRedeemed a DATETIME column?


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

nobby
Yak Posting Veteran

58 Posts

Posted - 2008-09-10 : 11:53:50
yes it is a datetime column
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-10 : 11:56:19
Recordset1_cmd.CommandText = "SELECT * FROM tblOrders WHERE DateRedeemed = '" & Format(Date(), "yyyymmdd") & "'"



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -