DateTimeValue function
Syntax
DateTimeValue(textdatetime)
Description
Use the DateTimeValue function to derive a DateTime value from a string representing a date and time.
Parameters
| Parameter | Description |
|---|---|
|
textdatetime |
Specify a date/time value represented as text in one of three formats:
In which:
|
Returns
Returns a DateTime value.
Example
Both of the following examples set &Date_TIME to a DateTime value equal to October 13, 1997 10:34:25 PM.:
&Date_TIME = DateTimeValue("10/13/97 10:34:25 PM");
&Date_TIME = DateTimeValue("10/13/97 22:34:25");
Assuming the base time (as defined in PSOPTIONS) is PST, the following three examples set &Date_TIME to a DateTime value equal to 2009-12-31-22.30.40.120000 UTC:
&Date_Time = DateTimeValue("2010-01-01 06:30:40.12Z");
&Date_Time = DateTimeValue("2010-01-01 00:30:40.12-0600");
&Date_Time = DateTimeValue("2010-01-01 10:30:40.12+04:00");
Using this Function in Fields Without a Default Century Setting
This function may derive the wrong century setting if passed a two-character year and DateTimeValue is executing in a PeopleCode event not associated with a field that has a default century setting.
For example, assume that TEST_DATE is a date field with a default century setting of 10. TEST_FIELD is a field with no default century setting. If the following PeopleCode program is executing in TEST_FIELD, the date will be calculated incorrectly:
TEST_DATE = DateTimeValue("10/13/11 15:34:25");
Although TEST_DATE has a century setting, it isn’t used because the PeopleCode fired in TEST_FIELD. Instead, DateTimeValue uses the 50/50 rule and calculates the year to be 2011 (instead of 1911).