> For the complete documentation index, see [llms.txt](https://docs.keyfax.biz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.keyfax.biz/product-suite/admin/databox-expressions/date-expressions/asdate.md).

# AsDate

Format a date held in a Databox.

The `AsDate` expression can be used in many ways to format a date held in [Databoxes](/product-suite/admin/entities/databoxes.md) . A comprehensive list of format specifiers follows:&#x20;

<table data-full-width="false"><thead><tr><th>Expression</th><th align="center">Databox Value</th><th align="center">Result</th><th>Comments</th></tr></thead><tbody><tr><td><code>AsDate</code></td><td align="center">15-10-2018 08:00pm</td><td align="center">15/10/2018 20:00:00</td><td>A date entry is converted into a simple date format</td></tr><tr><td><code>AsDate Format ("ddd dd MMM yyyy - HH:mm")</code></td><td align="center">15-10-2018 08:00pm</td><td align="center">Mon 15 Oct 2018 - 20:00</td><td>A date entry is formatted to the required layout</td></tr><tr><td><code>AsDate Format (‘d’)</code></td><td align="center">15-10-2018 08:00pm</td><td align="center">15/10/2018</td><td>A date entry is converted into day/month/year</td></tr><tr><td><code>AsDate Format (‘dd’)</code></td><td align="center">15-10-2018 08:00pm</td><td align="center">15 </td><td>A date entry is converted into day of the month</td></tr><tr><td><code>AsDate Format (‘ddd’)</code></td><td align="center">15-10-2018 08:00pm</td><td align="center">Mon</td><td>A date entry is converted into short name for day</td></tr><tr><td><code>AsDate Format (‘dddd’)</code></td><td align="center">15-10-2018 08:00pm</td><td align="center">Monday</td><td>A date entry is converted into full name for day</td></tr><tr><td><code>AsDate Format (‘D’)</code></td><td align="center">15-10-2018 08:00pm</td><td align="center">15 Oct 2018</td><td>A date entry is converted into day month year (with short month name)</td></tr><tr><td><code>AsDate Format (‘m')</code></td><td align="center">15-10-2018 08:00pm</td><td align="center">15 Oct</td><td>A date entry is converted into day month (with short month name)</td></tr><tr><td><code>AsDate Format (‘mm')</code></td><td align="center">15-10-2018 08:00pm</td><td align="center">00 (minutes)</td><td>A date entry is converted into the minutes past the hour</td></tr><tr><td><code>AsDate Format (‘MM’)</code></td><td align="center">15-10-2018 08:00pm</td><td align="center">10</td><td>A date entry is converted into the month</td></tr><tr><td><code>AsDate Format (‘MMM’)</code></td><td align="center">15-10-2018 08:00pm</td><td align="center">Oct</td><td>A date entry is converted into the month (with short month name)</td></tr><tr><td><code>AsDate Format (‘y’)</code></td><td align="center">15-10-2018 08:00pm</td><td align="center">Oct 2018</td><td>A date entry is converted into month year (with short month name)</td></tr><tr><td><code>AsDate Format (‘yy’)</code></td><td align="center">15-10-2018 08:00pm</td><td align="center">18</td><td>A date entry is converted into final two numbers of the year</td></tr><tr><td><code>AsDate Format (‘yyy’)</code></td><td align="center">15-10-2018 08:00pm</td><td align="center">2018</td><td>A date entry is converted into the year</td></tr><tr><td><code>AsDate BetweenDates(DateAdd(Today, -1, 'yyyy'), Today)</code></td><td align="center">2021-06-17 08:00:00Z</td><td align="center">Boolean</td><td>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.</td></tr></tbody></table>

### Example 1

Convert a [Company Data](/product-suite/admin/entities/databoxes/company-data.md) 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\...

<figure><img src="https://2882349412-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MARm6St_qFGM52R3pBa%2Fuploads%2F2AejrM6fA5GZ80eQGhln%2Fimage.png?alt=media&amp;token=7c3014c8-3108-4d8e-903f-62b4b9913e29" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2882349412-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MARm6St_qFGM52R3pBa%2Fuploads%2FnGogBxSnrQ3jpH2tQEPj%2Fimage.png?alt=media&amp;token=b5b38ae0-e689-44ce-b8c2-5316934796ef" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://2882349412-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MARm6St_qFGM52R3pBa%2Fuploads%2FOBFFE7fhkpONe9LVClP3%2Fimage.png?alt=media&amp;token=671d13bd-152c-4c65-8d6d-d02332e5d98e" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2882349412-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MARm6St_qFGM52R3pBa%2Fuploads%2FZFuMg3874hOTBaFhJr2J%2Fimage.png?alt=media&amp;token=30a631fe-03fe-4553-9f29-f8375acf40bf" alt=""><figcaption></figcaption></figure>

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.

<figure><img src="https://2882349412-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MARm6St_qFGM52R3pBa%2Fuploads%2FrwICRFlXoumh59m01Mzy%2Fimage.png?alt=media&amp;token=d5a5ae50-40e9-4ecb-9530-b4f511b5c148" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://2882349412-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MARm6St_qFGM52R3pBa%2Fuploads%2FJ9efUcXJCGov3MKrSdap%2Fimage.png?alt=media&amp;token=37658beb-ab7f-45f7-a0b6-6c300cf7750b" alt=""><figcaption></figcaption></figure>

### 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](/product-suite/admin/entities/databoxes/company-data.md) Databox.

<figure><img src="https://2882349412-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MARm6St_qFGM52R3pBa%2Fuploads%2FekC1sNTykwcZ7PMi3ZND%2Fimage.png?alt=media&amp;token=86d81297-70f6-4d0a-8a4d-71c74693332f" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2882349412-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MARm6St_qFGM52R3pBa%2Fuploads%2FkbN8DnYJc2A5er0FPzYH%2Fimage.png?alt=media&amp;token=86030eb7-ab96-4ece-9477-805cd976014b" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://2882349412-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MARm6St_qFGM52R3pBa%2Fuploads%2F2MEw8W5GhmCwDHKTNqyw%2Fimage.png?alt=media&amp;token=512135b7-d03c-46b9-a760-2fdda2c97974" alt=""><figcaption></figcaption></figure>

### 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"**

<figure><img src="https://2882349412-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MARm6St_qFGM52R3pBa%2Fuploads%2FI5JapcodZYlnI34jvzS4%2Fimage.png?alt=media&amp;token=fb76eb06-a8f5-42ac-990f-d02e7cb6ed06" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://2882349412-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MARm6St_qFGM52R3pBa%2Fuploads%2F7KI5tSQhHDykT1mVORzP%2Fimage.png?alt=media&amp;token=f40c91c8-1ad2-419d-8371-9d9694006827" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://2882349412-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MARm6St_qFGM52R3pBa%2Fuploads%2FLgkoFWZiLYW2Sd1omPgM%2Fimage.png?alt=media&amp;token=a46e26af-5be8-4407-b63d-b7a555299220" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2882349412-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MARm6St_qFGM52R3pBa%2Fuploads%2FKCWjX14XCRGoKo533SvK%2Fimage.png?alt=media&amp;token=51b31126-2f1a-4571-8ded-d8f79817c029" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2882349412-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MARm6St_qFGM52R3pBa%2Fuploads%2FmujWpSqwlWv3cesc63ET%2Fimage.png?alt=media&amp;token=3a9f1379-ea43-4260-a4ed-489d6150c87c" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2882349412-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MARm6St_qFGM52R3pBa%2Fuploads%2FvaMjv4tW0qU5T7rcLyr7%2Fimage.png?alt=media&amp;token=598af426-b25a-4b2d-bbc6-dfab6b61f867" alt=""><figcaption></figcaption></figure>
