# AsDate

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="/files/HrYiLRTFE2P9yZvnyceo" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/nhQQrr2pxcwGXfD5s6HI" 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="/files/Bbi33755uIOzrAPyBqSu" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/7gRwLgrnjXLoigaBYrYh" 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="/files/UZCcZ11jMT2Lu6SG85mh" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/DSeZjJKYhvN8N8t8bAtn" 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="/files/B0IkCT1rITNlL4eS7uIG" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/GmUmnB2Ie2D4aCtwnZSt" 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="/files/RTjLganbDUU0Ie9SIakB" 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="/files/prlCenppseCSWDC9lvsM" 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="/files/TCT5nwfBkW9V6jAfQYz7" 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="/files/yFDgtT6u9bRY8hgoDxiN" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/6cpeffCg2aZqIBpKSmMZ" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/U13DiJe4HjaIj9LuR7Ol" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/bMOXUNCnAXx605VyhR3W" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keyfax.biz/product-suite/admin/databox-expressions/date-expressions/asdate.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
