Extracting DAY part using FORMAT function in different formarts + SQL server 2012

Bandi
Posted by Bandi under Sql Server category on | Points: 40 | Views : 1129
FORMART function allows you to extract DAY part from a datetime value , also it is very useful to represent extracted part in different forms..

For example, the below code snippets explains you to extract DAY part from a DATETIME value in Full Date, only day in digits, simple day name, full day name forms...

SELECT FORMAT ( GETDATE(), 'd', 'en-US' ) AS US_Result; -- 3/20/2015
SELECT FORMAT ( GETDATE(), 'dd', 'en-US' ) AS US_Result; -- 20
SELECT FORMAT ( GETDATE(), 'ddd', 'en-US' ) AS US_Result; -- Fri
SELECT FORMAT ( GETDATE(), 'dddd', 'en-US' ) AS US_Result; --Friday

Comments or Responses

Login to post response