DateTimeFormat SQL Function

The DateTimeFormat() function takes three (3) arguments and formats given date time value in specific format using given culture infomration.

Th syntax for DateTimeFormat() is DateTimeFormat(DateTime Value , Format String , Culture Name) .

y yy yyy yyyy			// "8 08 008 2008"   		year
M MM MMM MMMM	// "3 03 Mar March"  		month
d dd ddd dddd		// "9 09 Sun Sunday" 		day
h hh H HH			// "4 04 16 16"      		hour 12/24
m mm				// "5 05"            		minute
s ss					// "7 07"            		second
f ff fff ffff			// "1 12 123 1230"   		sec.fraction
F FF FFF FFFF			// "1 12 123 123"    		without zeroes
t tt					// "P PM"            		A.M. or P.M.
z zz zzz				// "-6 -06 -06:00"   		time zone
d/M/yyyy HH:mm:ss		// "9/3/2008 16:05:07"
d/M/yyyy HH:mm:ss		// "9.3.2008 16:05:07" 		german (de-DE)
M/d/yyyy				// "3/9/2008"
MM/dd/yyyy				// "03/09/2008" /* day and month names */
ddd, MMM d, yyyy		// "Sun, Mar 9, 2008"
dddd, MMMM d, yyyy		// "Sunday, March 9, 2008" /* two to four digit year */
MM/dd/yy		// "03/09/08"
MM/dd/yyyy		// "03/09/2008"

/* Time Patterns */

t		// "4:05 PM" ShortTime
d		// "3/9/2008" ShortDate
T		// "4:05:07 PM"  LongTime
D		// "Sunday, March 09, 2008" LongDate
f		// "Sunday, March 09, 2008 4:05 PM" LongDate+ShortTime
F		// "Sunday, March 09, 2008 4:05:07 PM" FullDateTime
g		// "3/9/2008 4:05 PM"  ShortDate+ShortTime
G		// "3/9/2008 4:05:07 PM"  ShortDate+LongTime
m		// "March 09"  MonthDay
y		// "March, 2008"  YearMonth
r		// "Sun, 09 Mar 2008 16:05:07 GMT" RFC1123
s		// "2008-03-09T16:05:07"      	SortableDateTime
u		// "2008-03-09 16:05:07Z" UniversalSortableDateTime
	


		/* Following will output 2017-07-04 11:03:33 */ 
SELECT DateTimeFormat(GetDate(), 'yyyy-MM-dd HH:mm:ss', 'en-US') ;

/* Following will output 7 07 JUL July */
SELECT DateTimeFormat(GetDate(), 'M MM MMM MMMM', 'en-US') ;

/* Following will output 8 08 août août using french culture format */
SELECT DateTimeFormat(GetDate(), 'M MM MMM MMMM', 'fr-FR') ;

/* Following will output current time 11:17 AM */
SELECT DateTimeFormat(GetDate(), 't', 'en-US');