AsDate

Format a date held in a Databox.

The AsDate expression can be used in many ways to format a date held in Databoxes . A comprehensive list of format specifiers follows:

Expression
Databox Value
Result
Comments

AsDate

15-10-2018 08:00pm

15/10/2018 20:00:00

A date entry is converted into a simple date format

AsDate Format ("ddd dd MMM yyyy - HH:mm")

15-10-2018 08:00pm

Mon 15 Oct 2018 - 20:00

A date entry is formatted to the required layout

AsDate Format (‘d’)

15-10-2018 08:00pm

15/10/2018

A date entry is converted into day/month/year

AsDate Format (‘dd’)

15-10-2018 08:00pm

15

A date entry is converted into day of the month

AsDate Format (‘ddd’)

15-10-2018 08:00pm

Mon

A date entry is converted into short name for day

AsDate Format (‘dddd’)

15-10-2018 08:00pm

Monday

A date entry is converted into full name for day

AsDate Format (‘D’)

15-10-2018 08:00pm

15 Oct 2018

A date entry is converted into day month year (with short month name)

AsDate Format (‘m')

15-10-2018 08:00pm

15 Oct

A date entry is converted into day month (with short month name)

AsDate Format (‘mm')

15-10-2018 08:00pm

00 (minutes)

A date entry is converted into the minutes past the hour

AsDate Format (‘MM’)

15-10-2018 08:00pm

10

A date entry is converted into the month

AsDate Format (‘MMM’)

15-10-2018 08:00pm

Oct

A date entry is converted into the month (with short month name)

AsDate Format (‘y’)

15-10-2018 08:00pm

Oct 2018

A date entry is converted into month year (with short month name)

AsDate Format (‘yy’)

15-10-2018 08:00pm

18

A date entry is converted into final two numbers of the year

AsDate Format (‘yyy’)

15-10-2018 08:00pm

2018

A date entry is converted into the year

AsDate BetweenDates(DateAdd(Today, -1, 'yyyy'), Today)

2021-06-17 08:00:00Z

Boolean

AsDate can be combined with other Expressions. This example determines if the databox's date value falls within the last year, returning a boolean True or False value.

Example 1

Convert a Company Data Databox value to a date.

Databox CompanyData.Expressions.Date holds the value 15-10-2016 and using Examples.Date.AsDate in the message Expressions.EXPDATE it is converted into the format "ddd dd MMM yyyy". This is shown below...

The fixed value to be converted. In example 2 below we demonstrate a more useful conversion on a user supplied value.

This is the expression to convert it to a different format. Using the correct formats you can convert this date into almost any formats. Please see the table above for a complete list of format specifiers.

The message applies the expression and displays it as seen below.

Example 2

Convert a user entered date. This example follows the same format as the first but using a date entered by the user rather than a Company Data Databox.

Today's date is added for this example and the message displays this in same format as in the example above.

Example 3

Convert 24 hour time to 12 hour time. User enters time in the 24 hour format "HH:mm" and it is converted into and displayed as 12 hour time "hh:mm tt"

The user enters the time in question Time01, this is written into Examples.Date and then evaluated against Examples.Date.AsDate 24H->12H, the result is written into Script.Info01 and displayed in the message Expressions.EXPDATE08

Below the script has been run twice, once with an PM time and once with a AM time.

Last updated