Salesforce

How Do I Calculate an XML DateTime Format? (Magic xpi 4.7)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

How Do I Calculate an XML DateTime Format? (Magic xpi 4.7)

Magic xpi makes it easy to calculate an XML DateTime format. All you need to do it use one of the four Magic xpi functions provided for this: DateTimeFormat, GetDate, GetTime, or GetTimeZone.

Using the DateTimeFormat() function:

The syntax of DateTimeFormat() is:

DateTimeFormat(date, time, timezone, format)

Where:

date is any date variable (or a hard-coded date, such as '05/06/2008'DATE, or an expression that evaluates to a date).

The DATE that you see in the string above, '05/06/2008'DATE, is a Magic xpi literal. If you use this literal, the string is interpreted as a date. You can use it in arithmetic operations because it’s internally represented as a Numeric value. So, for example, '01/01/97'DATE+14 is a valid expression that yields the date 15/01/97.

time is any time variable (or a hard-coded time, such as '16:10:14'TIME, or an expression that evaluates to a time).

timezone is the time zone that you want to use relative to GMT.

format is whether you want it in XML DateTime format (1), which is YYYY-MM-DDThh:mm:ssTZD, or Julian Date format (2).

Here’s an example of how this function works:

If you have: DateTimeFormat('29/04/2008'Date, '10:45:30'Time, '+05:30',1), it returns 2008-04-29T10:45:30+5:30.

Using the GetDate() function:

This function accepts one DateTime string and returns the date section of the input value in Alpha format.

The syntax of GetDate() is:

GetDate(datetime, format)

Where:

datetime is a DateTime expression

format is whether you want it in XML DateTime format (1), which is YYYY-MM-DDThh:mm:ssTZD, or Julian Date format (2).

Here’s an example of how this function works:

If you have: GetDate('2008-04-29T10:45:30+5:30',1), it returns 2008-04-29.

Using the GetTime() function:

This function accepts one DateTime string and returns the time section of the input value in Alpha format.

The syntax of GetTime() is:

GetTime(datetime, format)

Where:

datetime is a DateTime expression

format is whether you want it in XML DateTime format (1), which is YYYY-MM-DDThh:mm:ssTZD, or Julian Date format (2).

Here’s an example of how this function works:

If you have: GetTime('2008-04-29T10:45:30+5:30',1), it returns 10:45:30.

Using the GetTimeZone() function:

This function accepts date and time input and returns the time zone section of the input value in Alpha format.

The syntax of GetTimeZone() is:

GetTimeZone(datetime, format)

Where:

datetime is a DateTime expression

format is whether you want it in XML DateTime format (1), which is YYYY-MM-DDThh:mm:ssTZD, or Julian Date format (2).

Here’s an example of how this function works:

If you have: GetTimeZone('2008-04-29T10:45:30+5:30',1), it returns +5:30.

See also: How Do I Calculate a Julian Date?

Reference
Attachment 
Attachment