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

Where Statement with SQL Server Using Dates

Status
Not open for further replies.

DavidArchibald

IS-IT--Management
Oct 29, 2000
20
0
0
NZ
Ahhhhhh, another fool who is struggling on this old chestnut!

I have a Datetime field in a SQL Server 7 table with a valid date in US format eg 9/25/2002.

The ASP/web server converts this to UK format (our locale format).

Even when I convert the date to US format, the recordset is empty.

SOO, what's the simplest way in the above scenario to do the following -

SELECT * FROM table_name WHERE table_field = date

Thanks in advance.
 
try:

strSQL = "SELECT * FROM table_name WHERE table_field ='" & date & "'"

or

strSQL = "SELECT * FROM table_name WHERE table_field ='#" & date & "#'"

or

strSQL = "SELECT * FROM table_name WHERE table_field ='" & month(date) & "/" & day(date) & "/" & Right(year(date),2) & "'"


one of those should work for you..

- Jason



www.vzio.com
ASP WEB DEVELOPMENT



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top