StrFTime SQL Function

The StrFTime() function formats date or time or DateTime value to requested format. It takes minimum two (2) arguments and returns formatted string.

Syntax : StrFTime( Format , Value)

Formating String Description
%d Day of month, 01-31
%f Fractional seconds, SS.SSS
%H Hour, 00-23
%j Day of year, 001-366
%J Julian day number, DDDD.DDDD
%m Month, 00-12
%M Minute, 00-59
%s Seconds since 1970-01-01
%S Seconds, 00-59
%w Day of week, 0-6 (0 is Sunday)
%W Week of year, 01-53
%Y Year, YYYY
%% % symbol


		/* Following will output Year Month Day from local date time due to GetDate() */ 
SELECT StrFTime('%Y %m %d', DateTimeFormat(GetDate(), 'yyyy-MM-dd HH:mm:ss', 'en-US'));

/* Following will output Year using UTC date year */
SELECT StrFTime('%Y', 'now');

/* Following is completely custom format Hour @ Minute year month and day */
SELECT StrFTime('%H - %M @ %Y %m %d', DateTimeFormat(GetDate(), 'yyyy-MM-dd HH:mm:ss', 'en-US'));

/* Following will produce : In UTC Year = 2017 , Month = 07 and day = 01 */
SELECT StrFTime('In UTC Year = %Y , Month = %m and day = %d', 'Now');