Salesforce

How Do I Convert a Date Value to a String? (Magic xpi 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

How Do I Convert a Date Value to a String? (Magic xpi 3.x)

A date value in Magic xpi is basically numeric, and stored as the number of days since the year zero. When you want to include the date in a string, you need to convert the date to a string. This is done using the DStr() function, as shown below.

Date Pictures

Whenever you display a date, you have a lot of formatting options in Magic xpi. The picture of the date determines how it is displayed. The picture is basically a kind of template that interprets the date. Letter placeholders are used to indicate how the date should be interpreted. For example, for the date “June 30th, 2007”:

Picture

How it displays as a string

Notes

MM/DD/YY

06/30/07

DD/MM/YYYY

30/06/2007

YYYYMMDD

20070630

YYYY-MM-DD

2007-06-30

YYYY

2007

YY

07

MMMM

June

DDD

181

Julian date (nth day of the year)

DDDD

30th

WWW

Sat

WWWWWWWWW

Saturday

##/##/####

Depends

Depends on the value defined in the DateMode setting in the Magic.ini file.

Using the DStr() function:

The syntax of DStr() is:

DStr (date, picture)

Returns: A formatted date string. DStr() uses pictures to format the string.

Here are some examples of how this function works.

When the DateMode setting in the Magic.ini file is set to A (for American),

DStr ('01/28/92'Date,'WWWWWWWW, MMMMMMMM DD, YYYY')

returns 'Tuesday, January 28, 1992'.

When the DateMode setting is set to E (for European), DStr('28/01/96'Date,'DD/MM/YY')

returns 28/01/96.

See also: How Do I Calculate a Date Value that Is Stored in a String?

Reference
Attachment 
Attachment