# dtos

### dtos()

Returns the current date as a string with the format "yyyyMMdd"

### dtos(date)

Returns the date given as a string with the format "yyyyMMdd". The date must be a real date value, not a string (e.g. as produced by the date() function).

### dtos(date, dateFmt)

Returns the given date as a string in the format given by dateFmt (see Date and Time Formatting).

## Arguments

Argument | Data Type | Description
date | date value | Date to convert to a string
dateFmt | string | String which holds the format to produce

## Returns

A string representing 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.
2. If you use a field id as the source of the date, Inaport will expect to find a real date/time value. If the field contains a string, Inaport will attempt to convert the string into a date value, using the default date format.

dtos() is used to produce a formatted date string, which is normally placed in a field.

The first form of the function return the current system date as the string "yyyyMMdd".

The second form is takes the date value passed and converts it to a date string in the format "yyyyMMdd".

The third form allows you to specify the format of the string used to supply the date value. For information about how to specify the format, see Date and Time Formatting.

## Examples

Assume that:

1. The current date is 13/05/01 at 14:45
2. Field F1 has a date value of 23/08/01 11:32
3. Field F2 has a string "21/04/01 13:32"

Example | Returns | Description
dtos() | "20010513" | Current date as "yyyyMMdd"
dtos(date()) | "20010513" | The date() function returns the current date, which dtos() then converts to "yyyyMMdd"
dtos(#F1) | "20010823" |
dtos(#F1, "MMMM yyyy") | "August 2001" | Tries to make a date using the value in field 1 using default format
date(#F2, "MM/dd/yy") | "04/21/01" | Tries to make a date value using the string in field 2 and the default format, then converts that date to a string formatted as "mm/dd/yy"

## See Also

date(), Date and time formatting