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
 manipulate time in a database

Author  Topic 

learning_grsql
Posting Yak Master

230 Posts

Posted - 2013-05-14 : 03:54:51
I have a time column with text data type similar to below :


1901
1902
1903
1903
1903
1904
1904
1905
1906
....
2100
2101
2102
2102
2103

And I want now it to change similar to below. Basically, when the time is 1901, the output should be 1730, when 1902 it is 1731 and so on...

1730
1731
1732
1732
1732
1733
1733
1734
1735
....
....
1929
1930
1931
1931
1932


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-14 : 04:15:03
[code]
SELECT CONVERT(varchar(5),DATEADD(ss,-91,STUFF([time],3,0,':')),108)
FROM TableName
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2013-05-17 : 07:09:22
select col,cast(col as int) -171 from your_table

Madhivanan

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

- Advertisement -