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
 Date

Author  Topic 

pravin14u
Posting Yak Master

246 Posts

Posted - 2007-03-02 : 02:28:49
Hi All,

I need to extract the data part only( Ex: 12-12-2006 and not 12-12-2006 10:40:000) from a smalldattime variable.

How can this be done?

( I dont want to use the Datepart functio thrice to get day, month and year separately)

Thanks,

Prakash.P

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-02 : 02:55:54
[code]
select dateadd(day, datediff(day, 0, @datevar), 0)
[/code]


KH

Go to Top of Page

Stevo
Starting Member

8 Posts

Posted - 2007-03-02 : 14:25:16
select convert(varchar(10),getDate(),105)

+Stevo
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-02 : 14:40:08
select dateadd(day, cast(@datevar - 0.50000004 as int), 0)


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -