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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL No DateSerial Function :(

Author  Topic 

jgd12345
Starting Member

6 Posts

Posted - 2006-01-04 : 05:29:33
Hi, I wish to create a query to list all the events that lie on a specific day. Each event has a start date and end date, I'm using sql server with asp and originally I tried:

SELECT * FROM tbdEvents WHERE fldStartDate <= dateSerial(" & vntYear & "," & vntMonth & "," & vntDay & ") AND fldEndDate >= dateSerial(" & vntYear & "," & vntMonth & "," & vntDay & "


But I've just realized that SQL does not have a dateSerial function. I'd appreciate it if someone could help. Thanks

Frank Kalis
Constraint Violating Yak Guru

413 Posts

Posted - 2006-01-04 : 05:44:17
Are you looking for this

DECLARE @yr INT, @mth INT, @d INT
SELECT @yr = 2006, @mth = 1, @d = 4
SELECT CAST(@yr * 10000 + @mth * 100 + @d AS CHAR(8))
, CAST(CAST(@yr * 10000 + @mth * 100 + @d AS CHAR(8)) AS SMALLDATETIME)


-------- ------------------------------------------------------
20060104 2006-01-04 00:00:00

(1 row(s) affected)


--
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Heute schon gebloggt? http://www.insidesql.de/blogs
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-01-04 : 07:28:39
see:

http://weblogs.sqlteam.com/jeffs/archive/2003/12/09/646.aspx

for a UDF version of dateserial().
Go to Top of Page
   

- Advertisement -