SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 return date part only
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

eugz
Posting Yak Master

195 Posts

Posted - 09/13/2013 :  11:48:09  Show Profile  Reply with Quote
Hi All.

I'm using SQL Server 2008. I table datetime fild display value like 2008-09-22 15:24:00.000.
How to modify function
DATEADD(DD, 0, DATEDIFF(DD, 0, DateField)) as Date
to get result like mm/dd/yyyy?

Thanks

Edited by - eugz on 09/13/2013 11:48:36

Lamprey
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 09/13/2013 :  12:02:09  Show Profile  Reply with Quote
You can use the CONVERT function to convert and format the date as a string, but that is really something you should let your presentation layer handle.
SELECT CONVERT(VARCHAR(10), GETDATE(), 101)


http://technet.microsoft.com/en-us/library/ms187928.aspx

EDIT: Forgot code sample

Edited by - Lamprey on 09/13/2013 12:03:36
Go to Top of Page

jeffw8713
Aged Yak Warrior

USA
798 Posts

Posted - 09/13/2013 :  15:23:20  Show Profile  Reply with Quote
You can just cast it to a date. CAST(getdate() as date)
Go to Top of Page

jeffw8713
Aged Yak Warrior

USA
798 Posts

Posted - 09/13/2013 :  15:23:43  Show Profile  Reply with Quote
You can just cast it to a date. CAST(getdate() as date)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000