4D v13.4

DATE_TO_CHAR

Home

 
4D v13.4
DATE_TO_CHAR

DATE_TO_CHAR  


 

 

Command DATE_TO_CHAR

DATE_TO_CHAR (arithmetic_expression, arithmetic_expression)

The DATE_TO_CHAR function returns a text representation of the date passed in the first arithmetic_expression according to the format specified in the second arithmetic_expression. The first arithmetic_expression should be of the Timestamp or Duration type and the second should be of the Text type.

The formatting flags which can be used are given below. In general, if a formatting flag starts with an upper-case character and produces a zero, then the number will start with one or more zeros when appropriate; otherwise, there will be no leading zeros. For example, if dd returns 7, then Dd will return 07.

The use of upper- and lower-case characters in the formatting flags for day and month names will be reproduced in the results returned. For example, passing "day" will return "monday", passing "Day" will return "Monday" and passing "DAY" will return "MONDAY".

am - am or pm according to the value of the hour
pm - am or pm according to the value of the hour
a.m. - a.m. or p.m. according to the value of the hour
p.m. - a.m. or p.m. according to the value of the hour

d - numeric day of week (1-7)
dd - numeric day of month (1-31)
ddd - numeric day of year
day - name of day of week
dy - abbreviated 3-letter name of day of week

hh - numeric hour, 12-based (0-11)
hh12 - numeric hour, 12-based (0-11)
hh24 - numeric hour, 24-based (0-23)

J - Julian day

mi - minutes (0-59)
mm - numeric month (0-12)

q - year's quarter

ss - seconds (0-59)
sss - milliseconds (0-999)

w - week of month (1-5)
ww - week of year (1-53)

yy - year
yyyy - year

[any text] - text inside brackets ([ ]) is not interpreted and inserted as is
-.,:; 'space character' 'tab character' - are left as is, without changes.

Example  

This example returns the birth date as a numeric day of the week (1-7):

SELECT DATE_TO_CHAR (Birth_Date,’d’)
FROM EMPLOYERS;

 
PROPERTIES 

Product: 4D
Theme: Functions

 
INDEX

Alphabetical list of commands