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)
 Filtering using SmallDateTime

Author  Topic 

RichardSteele
Posting Yak Master

160 Posts

Posted - 2004-09-01 : 14:57:19
I want to pull records that were entered today.

What is the correct syntax for
Select * from mailinglist where xdate='09/01/2004'?

xdate is a smalldatetime field that has a date and time in it. Many thanks in advance.

JimL
SQL Slinging Yak Ranger

1537 Posts

Posted - 2004-09-01 : 15:21:54
Select a,b,c (do not use *)

From Mailinglist

where Convert(varchar(50),xdate,101) = Convert(varchar(50),GETDATE(),101)

Jim
Users <> Logic
Go to Top of Page

RichardSteele
Posting Yak Master

160 Posts

Posted - 2004-09-01 : 19:25:53
Thanks, that did it.

What would an update look like if I wanted to update the xdate with a random date (time is not always needed)?

What's the best reference for SQL Syntax?



Go to Top of Page

benjamintb
Starting Member

15 Posts

Posted - 2004-09-01 : 21:47:19
UPDATE mailinglist
SET xdate = cast('1/01/2004' as smalldatetime)

should do it.

If you need to find any infor about sql syntax the best reference is 'books online'. It should be installed with sql server. It tells you pretty much everything about sql server. And if your not using sql server you can download books online from the microsoft website anyway.
Go to Top of Page
   

- Advertisement -