# toDateOnly(string, format)

Converts a date in string format to a `DateOnly` type. *format* specifies the date format and can be any valid date format.

:::note
You can only use this function when the time zone feature is enabled. If the time zone feature is disabled, use the [toDate()](/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-todate.md) function.
:::

```nolang
q = foreach q generate toDateOnly('CloseDate',"yyyy/MM/dd") as DateTime;
```
