Handling Date and Time

Data Types

In Appian you can store a point in time using a variable with a Date and Time data type, which differs from the Date data type and the Time data type.

 

 

Date

DateTime

Time

How is it saved in the database?

Date data is stored as entered without conversion to a time zone.

Datetimes are saved from Appian in the database in GMT.

Time data is stored as entered without conversion to a time zone.

How does it display on a SAIL form?

Appian will read a date as it is stored in the database without any conversion based on timezone.

Appian will read a dateTime and display it in the logged-in-user’s specified timezone.

Appian will read a time as it is stored in the database without any conversion based on timezone.

Possible Display Formats on a SAIL form

January 1, 2000

01/01/2000

2017-01-01: 05:00:00

2:00 pm

14:00

 

All Date and Time values (also called Datetime values) are stored in Greenwich Mean Time (GMT) in the database, and all Date and Time functions assume values passed to them are in GMT.

If a function expects a Date and Time value, and you pass it a date, the date is automatically converted to a Date and Time value, using 12:00 am for the time component.

When Datetime values are presented to users in the interface, they are always adjusted to the current user's time zone. This may cause the expected output to vary significantly. Additionally, the acronym of the user's local time zone (such as EDT) is appended to a displayed Datetime value when it appears in a form, an alert, or in an email.

See also: Data Types

For more information on setting your time zone, see also: Configuring the Default Language and Timezone

Common Conversions and Casting

Converting a DateTime to a Date

  • Wrap todate() around your dateTime. This function will accept both numerical and text values. If you are unable to successfully cast to a dateTime using this function, you can alternatively use the datetime() function to pass in individual parameters such as the year, month, day, hour, minute, second, and millisecond.
  • Example 1: If now() returns 1/23/2017 4:00 PM EST, then todate(now()) returns 1/23/2017.
  • Example 2: The todate() function operates on the GMT value of the given dateTime. For example, a dateTime may display as 04/01/2017 8:00 PM EST on a form, but wrapping todate() around it will return 04/02/2017 (the GMT value).
  • Example 3: To return a localized date, use the local() function. In the above example, todate() returns the next day, however, todate(local(ri!datetime, “EST”)) would return 04/1/2017.

Converting a Date to a DateTime

  • Wrap todatetime() around your date. This function will accept both numerical and text values. If you are unable to successfully cast to a dateTime using this function, you can use the date() function to pass in individual parameters such as year, month, and day.
  • When converting a date to a dateTime, the time value will be 12:00 AM GMT.
  • Example 1: todatetime(“12/13/2005”) returns 12/13/05 12:00 AM GMT.

Converting a String to a Time or Extracting the Time from a DateTime

  • Use the time() function and pass in individual parameters for hour, minute, and second. To extract the time from a dateTime such as now(), type: time(hour(now()), minute(now()), second(now())).
  • Example 1: totime(“5:50 PM”) returns 5:50 PM
  • Example 2:totime(datetime(2014, 1, 1, 5, 59)) returns 5:59 AM.

 For the full list of Appian Functions, see also: Appian Functions