Thursday, July 29, 2010

Convert a date to show AM/PM in SQL

Today I was working on a date column -- create_date. I wanted to show whether the row was created in the morning or in the evening i.e., AM/PM

This is what I did to achieve this.


SELECT rn_create_date, SUBSTRING(CONVERT(varchar(20), Rn_create_date, 22), 18, 3) AS Expr1
FROM tablename;



Here is the link to the BIDN blog where I have posted

No comments:

Free Power BI Classes week 5

Yesterday I completed the Power BI Class for week 5 We continued with Lab 3 and completed both Lab 3 and 4. The participants learnt about fo...