Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. Declare @S varchar(50)='2017092018'
  2.  
  3. Select convert(datetime,left(@S,8)) + convert(datetime,right(@S,2)+':00')
  4.  
  5. 2017-09-20 18:00:00.000
  6.  
  7. DECLARE @d NVARCHAR(10)='2017092018';
  8.  
  9. SELECT DATETIMEFROMPARTS(LEFT(@d, 4),SUBSTRING(@d,5,2),SUBSTRING(@d,7,2), RIGHT(@d,2),0,0,0 ) ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement