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
 remove the time in the results

Author  Topic 

shemayb
Posting Yak Master

159 Posts

Posted - 2007-12-19 : 17:12:59
i have this query: SELECT top 1 DATEADD(year, -2, @sDate)AS ydate which returns 2005-01-01 00:00:00.000,how can i remove the time values and only display the date?

thanks!

Funnyfrog

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-12-19 : 17:18:58
You can chop it off via CONVERT function with the appropriate style. But you should be handling this at the presentation layer instead of at the database layer.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

shemayb
Posting Yak Master

159 Posts

Posted - 2007-12-19 : 17:51:45
I changed my query to this one,SELECT DATEADD(year, -2, convert(char,@sDate,107)) AS ydate..but the result is still 2005-01-01 00:00:00.000...what is wrong with my query?

Funnyfrog
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-19 : 17:54:06
SELECT CONVERT(CHAR(10), DATEADD(YEAR, -2, @sDate), 112)



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-20 : 01:35:28
quote:
Originally posted by shemayb

i have this query: SELECT top 1 DATEADD(year, -2, @sDate)AS ydate which returns 2005-01-01 00:00:00.000,how can i remove the time values and only display the date?

thanks!

Funnyfrog


Where do you want to show data?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-12-20 : 08:28:44
also see:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210&SearchTerms=Getting%20the%20date%20portion%20of%20a%20datetime%20value


elsasoft.org
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-12-20 : 09:40:37
Please read this:

http://weblogs.sqlteam.com/jeffs/archive/2007/04/13/60175.aspx


- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -