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
 manipulate time in a database
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

learning_grsql
Posting Yak Master

230 Posts

Posted - 05/14/2013 :  03:54:51  Show Profile  Reply with Quote
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

India
52325 Posts

Posted - 05/14/2013 :  04:15:03  Show Profile  Reply with Quote

SELECT CONVERT(varchar(5),DATEADD(ss,-91,STUFF([time],3,0,':')),108)
FROM TableName


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

madhivanan
Premature Yak Congratulator

India
22769 Posts

Posted - 05/17/2013 :  07:09:22  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
select col,cast(col as int) -171 from your_table

Madhivanan

Failing to plan is Planning to fail
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.06 seconds. Powered By: Snitz Forums 2000