I have the following code which is working great for me. I am using it in a SSIS package in SQL. The issue i am having is that between midnight and 1:00 AM, the hour is showing up as 00. I would like to stay with the following code as much as possible, as it is working for me, but just make the needed adjustement. Any help would be greatly apprecieated!!!
Thank you,
John
SELECT CASE WHEN DATEPART(hour, DateTimeField) < 13 THEN
RIGHT(REPLICATE(' ', 2) + CAST(datepart(hour, DateTimeField) AS VARCHAR(2)), 2)
ELSE
RIGHT(REPLICATE(' ', 2) + CAST(datepart(hour, dateadd(hour, - 12, DateTimeField))
AS VARCHAR(2)), 2) END
I think you could simply do this instead: