util.Datetime.format()

util.Datetime.format() formats a DATETIME value according to the specified format.

Syntax

util.Datetime.format(value, format)

Parameters

value

a DATETIME value that must be formatted

format

a format string (STRING)

Usage and Examples

util.Datetime.format() takes a DATETIME value and formats it according to the specified format:

DISPLAY util.Datetime.format(CURRENT,"%Y-%m-%d %H:%M")

Example output:

2015-08-30 14:35

The Format String

A format string is a set of placeholders - for instance, the combination of %Y%m%d is representing different parts of a DATETIME value (those can be year, month, day, hour, minute, second, and fraction).

The table below lists the symbols that can be used in a format string.

All the characters absent from the table are interpreted as literals and are added as-is to the resulting string.

All dates are formatted according to the Gregorian calendar.

placeholder

description

%A

a full name of the week day

%a

an abbreviated name of the week day

%B

a full name of the month

%b or %h

an abbreviated name of the month

%C

a number of the century (0-99)

%c

date and time represented using the time and date formats of the application  locale

%D

an equivalent to %m/%d/%y

%d

a day in a month in a 2-digit format (01-31)

%e

a day in a month in a 1- or 2-digit format (1-31)

%F

a fraction of a second

%H or %k

an hour of a 24-hour clock (00-23)

%I

an hour of a 12-hour clock (1-12)

%y

a year in a 2-digit format (00-99). Note: This format does not distinguish between centuries, so it is recommended to use %Y instead for a full year representation

%Y

a year in a 4-digit format (e.g., 2001-2100)

%m

a month in a year in a 2-digit format (01-12)

%M

a minute

%n

a newline character

%p

an equivalent of AM or PM used in the application locale

%R

an equivalent to %H:%M

%r

an equivalent to %I:%M:%S %p in the POSIX locale

%S

a second

%T

an equivalent to %I:%M:%S

%t

a TAB character

%X

time represented using the time format of the application locale

%x

date represented using the date format of the application locale

%w

an ordinal number of a week day (0-6, starting with Sunday)

Here are some examples of the formatted DATETIME values:

format string

DATETIME value

resulting string

%Y-%m-%d %H:%M

2017-02-22 12:15:43.032

2017-02-22 12:15

%Y/%m/%d %H:%M:%S:%F

2017/02/22 12:15:43.032

%d-%m-%y %H:%M

22-02-17 12:15

%d-%B-%Y %H:%M:%S

22-February-2017 12:15:43

%Y-%b-%d (%a) %I:%M

2017-Feb-22 (Wed) 12:15

%A, %B %d

Wednesday, February 22

%Y-%m-%d %p

2017-02-22 PM

%T

12:15:43

[%d %h %Y %H:%M:%S]

[22 Feb 2017 12:15:43]

%B %d, %Y

February 22, 2017

%w %t = %t %A

3  =  Wednesday

%D %n %H:%M

02/22/17 12:15

If the source value is NULL, util.Datetime.format() will return NULL.

example code #1

MAIN

    DISPLAY CURRENT

    DISPLAY util.Datetime.format(CURRENT, "%Y-%m-%d %H:%M")

  CALL fgl_getkey()

END MAIN

obtained results #1

example code #2

MAIN

    DISPLAY util.Datetime.format(CURRENT, "%c")

    DISPLAY util.Datetime.format(CURRENT, "%x")

    DISPLAY util.Datetime.format(CURRENT, "%X")

  CALL fgl_getkey()

END MAIN

obtained results #2

 

Contact Us

Privacy Policy

Copyright © 2026 Querix, (UK) Ltd.