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
 Save Date without time ?

Author  Topic 

realdrouin
Starting Member

4 Posts

Posted - 2009-10-16 : 10:20:49
Is there's a way to save a date witout the time ?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-10-16 : 10:24:25
yes.

dateadd(day, datediff(day, 0, getdate()), 0)



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2009-10-16 : 10:27:12
Or if you are using SQL Server 2008, you can use the new date datatype.
Go to Top of Page

kbarne
Starting Member

4 Posts

Posted - 2009-10-16 : 22:52:09
Unfortunately, at least in SQL Server 2005 express the suggested code still returns all the zeroes. I'm trying to save just the date so that when displayed on my Web page one can sort by date and not have to see 00:00:00:00 after every date. Using Convert(nvarchar...) leads to not being able to sort by date.

Ken
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-10-16 : 23:09:18
format the date to your required format in your web page. Don't convert the date to string.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

kbarne
Starting Member

4 Posts

Posted - 2009-10-17 : 17:34:23
Thank you KH that did the trick!

Ken
Go to Top of Page
   

- Advertisement -