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 2005 Forums
 Transact-SQL (2005)
 date help

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2007-08-29 : 13:02:10
can someone help me with how to select a date from my table in the format of

mm/dd/yyy hh:mm and subtract 3 hours from it

can someone help me with the code?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-29 : 13:03:52
SELECT DATEADD(HOUR, -3, Col1)
FROM Table1



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

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2007-08-29 : 13:06:24
thanks but how can i format that to be
mm/dd/yyyy hh:mm
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-29 : 13:12:37
Is there some restriction for you having the front-end application formatting the datetime?

SELECT CONVERT(CHAR(10), DATEADD(HOUR, -3, Col1), 101) + ' ' + CONVERT(CHAR(5), DATEADD(HOUR, -3, Col1), 108)
FROM Table1



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

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-08-29 : 14:09:53
never worry about date formats in SQL Server! Always use datetime *values* with the correct data types throughout your database code, and let any clients that process your output format the dates any way they want.

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

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2007-08-29 : 14:17:39
thanks
Go to Top of Page
   

- Advertisement -