# date

### date()

Return the current date and time as a date type

### date(dateStr)

Return the date represented by the string using the default date/time format. The default format is yyyyMMdd (see Date and Time Formatting)

### date(dateStr, dateFormat)

Return the date represented by the string, using the format of dateFmt (see Date and Time Formatting)

## Arguments

Argument | Data Type | Description
dateStr | string | String to convert to a date
dateFormat | string | String which holds to format of dateStr If this is not supplied, dateStr is assumed to be in a format compatible with your local machine regional settings

## Returns

A date value.

## Description

NOTE:

1. Date values in Inaport, and most data sources such as Excel, Access and SQL Server, hold both the date and the time.

date() is used for creating date/time values, which may be placed in fields or used in expressions.

The first form of the function is used to create a date value equal to the current system date and time.

The second form is used to take a string such as "21/08/01 11:32" and convert it to a date value. This form assumes that the string is in the default format for your country: for example, the default format for the United States is "MM/dd/yy hh:mm". If the string is not in the correct format, the function will fail.

The third form allows you to specify the format of the string used to supply the date value.

## Examples

Example | Returns | Description
date() | date value |
date("11/21/05") | date value | date value with the given date. Assumes that the machine has a date format of "MM/dd/yy"
date("23/Aug/2001", "dd/MMM/yyyy") | date value | date value, using the format supplied to read the given date string
date(#MyField) | date value | Tries to make a date using the value in field MyField using default format
date(#MyField, "MM/dd/yy") | date value | Tries to make a date value using the string in field MyField, using the format "MM/dd/yy"

## See Also

dtos(), Date and time formatting