HomeGuidesRecipesAPI
HomeGuidesAPILog In
Guides
These docs are for v16. Click to read the latest docs for v31.

Date and Times

Date and time variables

SmartIQ provides four Date and Time variables - Date, Time, System Date and System Time. “System Date” and “System Time” uses the time zone from the hosting server whereas "Date" and "Time" uses the current users’ time zone.

For example, let the server time zone be 31/12/2012 10:30 PM and the user time zone be 01/01/2013 04:00 AM. Then,

System Date = 31/12/2012

System Time = 10:30 PM

Date = 01/01/2013

Time = 04:00 AM

Date Validation

Often when entering dates via Produce or receiving them from a data source, validation should be applied to ensure the date is accurate. Below are some common examples that can be adapted to suit your situation.

Future Date/Date cannot be in the past (example above)

Type: Compare

Comparison: Greater Than

Expression: today()

Message: ‘Your Message’

📘

Note

  1. Change the comparison to greater than or equals to include the current day.
  2. Change the comparison type to less than etc to ensure the date is in the past.

At least ‘X’ Days, years, months etc. difference
The dateadd formula can be used to ensure the time difference is greater than a certain integer. For example, ensure an applicant is over 18 or the delivery date is at least two weeks into the future.

Type: Compare

Comparison: Less Than or Equal

Expression: DateAdd(0,-18,today())

Message: ‘Applicant must be 18 years old’

📘

Note:

Change the comparison property together with the date add function (0=years and units -18) to suit your situation.

Named Date/Time Formats

Format NameDescription
General Date, or GDisplays a date and/or time. For real numbers, display a date and time; for example, 4/3/93 05:34 PM. If there is no fractional part, display only a date, for example, 4/3/93. If there is no integer part, display time only, for example, 05:34 PM. Date display is determined by your system's LocaleID value.
Long Date, or DDisplays a date according to your locale's long date format.
Medium DateDisplays a date using the medium date format appropriate for the language version of the host application.
Short Date, or dDisplays a date using your locale's short date format.
Long Time, or TDisplays a time using your locale's long time format; includes hours, minutes, seconds.
Medium TimeDisplays time in 12-hour format using hours and minutes and the AM/PM designator.
Short Time, or tDisplays a time using the 24-hour format, for example, 17:45.
Relative or RelDisplays a snippet of text describing a past date and time

Less than 2 mins "Just now"
Between 2 and 55 mins "X mins ago"
Between 55 mins and 90 mins "An hour ago"
Between 90 mins and 23.5 hours "X hours ago"
Between 23.5 and 2 days "A day ago"
Between 2 days and 7 days "X days ago"
Over 7 days and within the same year "1 Jan or Jan 1" according to the user's culture.
Over 7 days and in a different year "22/01/2019" according to the user's culture
fDisplays the long date and short time according to your locale's format.
FDisplays the long date and long time according to your locale's format.
gDisplays the short date and short time according to your locale's format.
M, mDisplays the month and the day of a date.
R, rFormats the date and time as Greenwich Mean Time (GMT)
sFormats the date and time as a sortable index.
uFormats the date and time as a GMT sortable index.
UFormats the date and time with the long date and long time as GMT.
Y, yFormats the date as the year and month.

Date's month digit appears as 00

Problem

When formatting a date the month will appear as 00 if a lowercase 'mm' has been used within the format string.

As in the example below:

DateFormat StringOutput
25/12/2020dd/mm/yyyy25/00/2020
25/12/2020dd/MM/yyyy25/12/2020

Solution

The incorrect month is due to the lower case 'm' character referring to the minute value whereas the upper case 'M' referrers to the month value.

Dates format appears with 12 00 00AM in the generated document

Problem

Questions with the data type set to 'Date' will return the date formatted in the long date format as in the following example:

371

Solution

All dates are processed in the time/date format and if a time isn't specified 12:00 AM will be assumed. To remove the unwanted time a format string such as SHORT DATE, LONG DATE, dd/MM/yyyy must be used. Apply a format string by specifying the appropriate sting under the Answer properties.

642

See Format Strings in the Designer Guide for more information.