DateTimeToLocalizedString function

Syntax

DateTimeToLocalizedString({datetime | date}, [Pattern])

Description

Use the DateTimeToLocalizedString function to convert either datetime or date to a localized string. You can also specify a particular pattern to convert datetime or date to.

The Pattern is optional. Only specify Pattern if necessary.

If you need to change the pattern for each language, change the first message in Message Catalog set number 138. This is a format for each language.

Parameters

Parameter Description

datetime | date

Specify either the DateTime or Date value that you want to convert.

Pattern

Specify the pattern you want to the localized DateTime or Date value to be converted to.

Returns

A string.

Example

REM**************************************************************; 
Function ConvertDateToDTTM(&Date As date) Returns DateTime ; 
REM ***********************************************************; 
   &String = DateTimeToLocalizedString(&Date, "M/d/y"); 
   &String = &String | " 00:00:00.000000"; 
   &DateTime = DateTimeValue(&String); 
   Return &DateTime; 
End-Function;

Using the Pattern Parameter

Pattern takes a string value, and indicates how you want the DateTime or Date value converted.

The valid values for Pattern are as follows.

Note:

The values for pattern are case-sensitive. For example, if you specify a lowercase m, you get minutes, while an uppercase M displays the month.

Symbol Definition Type Example

G

Era designator

Text

AD

y

Year

Number

1996

M

Month in year

Text&Number

July&07

d

Day in month

Number

10

h

Hour in am/pm

Number (1-12)

12

H

Hour in day

Number (0-23)

0

m

Minute in hour

Number

30

s

Second in minute

Number

55

S

Millisecond

Number

978

E

Day in week

Text

Tuesday

a

am/pm marker

Text

PM

k

Hour in day

Number (1-24)

24

K

Hour in am/pm

Number (0-11)

0

'

Escape for text

Delimiter

 

''

Single quote

Literal

'

The number of pattern letters determine the format.

Type Pattern Format

Text

If 4 or more pattern letters are used, the full form is used. If less than 4 pattern letters are used, the short or abbreviated form is used if one exists.

Number

Use the minimum number of digits. Shorter numbers are zero-padded to this amount.

The year is handled specially; that is, if the count of 'y' is 2, the year is truncated to 2 digits.

Text&Number

If 3 or more pattern letters are used, text is used, otherwise, a number is used.

Any characters in Pattern are not in the ranges of ['a'..'z'] and ['A'..'Z'] are treated as quoted text. For instance, characters like ':', '.', ' ', '#' and '@' appear in the resulting string even they're not within single quotes.

A pattern containing any invalid pattern letter results in a runtime error.

Examples using a United States locale:

Pattern Result

"yyyy.MM.dd G 'at' hh:mm:ss"

1996.07.10 AD at 15:08:56

"EEE, MMM d, ''yy"

Wed, July 10, '96

"h:mm a"

12:08 PM

"hh 'o''clock' a"

12 o'clock PM

"K:mm a"

0:00 PM

"yyyyy.MMMMM.dd GGG hh:mm aaa"

1996.July.10 AD 12:08 PM