문제

I am trying to convert from "tick" date format to a datetime format. Example:

0000113326 to 2013-11-22 00:00:00.000

I know how to go the opposite way:

SELECT '00001' + RIGHT(CAST(YEAR(StartDate) AS varCHAR(4)), 2) + RIGHT('000' + CAST(Datepart(dy, StartDate) AS VARCHAR(3)), 3)
FROM table

I just need to reverse engineer it.

Any ideas?

도움이 되었습니까?

해결책

Something like this?

DECLARE @tick varchar(20) = '0000113326'
SELECT dateadd(d, cast(right(@tick, 3) as int) - 1, '20' + substring(@tick, 6, 2) + '0101')
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top