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 2012 Forums
 Transact-SQL (2012)
 how to subtract days from the given format

Author  Topic 

madpop1
Starting Member

4 Posts

Posted - 2014-12-02 : 05:07:05
hi guys can tell me " how to subtract days from the given format "
format : Mon, 03 Nov 2014 14:10:00 GMT and it is in varchar(50) uunder dates column the data is inserted

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-12-02 : 09:14:46
e.g.


declare @d varchar(50) = 'Mon, 03 Nov 2014 14:10:00 GMT'
select cast(substring(@d, charindex(',', @d,1)+2, 11) as datetime) -1
Go to Top of Page

viggneshwar
Yak Posting Veteran

86 Posts

Posted - 2014-12-12 : 03:32:49
declare @d varchar(50) = 'Mon, 03 Nov 2014 14:10:00 GMT'
select cast(substring(@d, 6, 11) as datetime)

Regards
Viggneshwar A
Go to Top of Page
   

- Advertisement -