daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Jan 19th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT STUFF(STUFF('84936',3,0,'-'),6,0,'-')
  2.    
  3. SELECT STUFF(STUFF(RIGHT('0' + '84936', 6),3,0,':'),6,0,':');
  4.    
  5. 08:49:36
  6.    
  7. SELECT CONVERT(DATETIME, STUFF(STUFF(RIGHT('0' + '84936', 6),3,0,':'),6,0,':'));
  8.    
  9. 1900-01-01 08:49:36.000
  10.    
  11. declare @t varchar(6) = '92845';
  12. declare @fullt char(6) = RIGHT('000000' + @t,6)
  13.  
  14. select DATEADD(second,
  15.      SUBSTRING(@fullt,1,2) * 3600 +
  16.      SUBSTRING(@fullt,3,2) * 60 +
  17.      SUBSTRING(@fullt,5,2),0)
  18.    
  19. 1900-01-01 09:28:45.000
  20.    
  21. declare @t varchar(6) = '134524'
  22. select CASE WHEN len(@t)=5 then convert(datetime,convert(varchar(10),CAST(getdate() as date))+' '+'0'+LEFT(@t,1)+':'+SUBSTRING(@t,2,2)+':'+SUBSTRING(@t,4,2))
  23. else convert(datetime,convert(varchar(10),CAST(getdate() as date))+' '+LEFT(@t,2)+':'+SUBSTRING(@t,3,2)+':'+SUBSTRING(@t,5,2)) end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top