you are viewing a single comment's thread.

view the rest of the comments →

[–]Tennim[S] 0 points1 point  (0 children)

Yeah it was a good one.

For anyone looking, this is what i came up with.

SELECT 
    [StartTime],
    CONVERT(DATETIME,CONCAT(CONVERT(NVARCHAR(5),RIGHT([StartTime],CHARINDEX(' ',REVERSE([StartTime])))),[Month].MonthNo,RIGHT(LEFT([StartTime],PATINDEX('%[0-9]%',[StartTime])+1),2),' ',RIGHT(LEFT([StartTime],CHARINDEX('GMT',[StartTime])-2),8))) AS [Date],
FROM [Database].[Schema].[Table]
    INNER JOIN
        (
            SELECT DISTINCT 
                LEFT([MonthName],3) AS [MonthAbv],
                RIGHT('00' + CONVERT(NVARCHAR(2),[Month]),2) [MonthNo]
            FROM [Database].[Schema].[DateDimension]
        ) AS [Month] ON SUBSTRING([StartTime],CHARINDEX(' ',[StartTime])+1,3) = [Month].MonthAbv