[dba-SQLServer] Date syntax in SQL Server

Jim Lawrence (AccessD) accessd at shaw.ca
Sun Jun 13 01:30:59 CDT 2004

Hi John:

In my SP, I would probably create a variable like:

Declare @CheckDate Datetime
Select @CheckDate = convert(datetime,'1970-01-01',102))

...and then use the variable in the Where clause:

WHERE (DateOfBirth >= @CheckDate

...or when you put dates directly into the query:

WHERE (DateOfBirth between '01-Apr-2003' and '31-mar-2004'


-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of jwcolby
Sent: Saturday, June 12, 2004 8:46 PM
To: 'Access Developers discussion and problem solving'; SQLServer
Subject: [dba-SQLServer] Date syntax in SQL Server

What is the syntax for dates in SQL Server?

WHERE     (DateOfBirth >= CONVERT(DATETIME, '1970-01-01', 102))

I need to get rid of the convert.  Bracketing in ## doesn't work.

John W. Colby 

dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com

More information about the dba-SQLServer mailing list