---
schema_version: "1"
id: fddb6f60b092e268572d88c3574efd077887e965080bf17fd17cdbc13efff3c3
title: toDateOnly(string, format)
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_saql/guides/concept/bi-saql-functions-timezone-dateonly-string.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-timezone-dateonly-string.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 99f8446ca6e0263b8a83e4932ca2c1e66c278b3d719ec02a4d28870a1a841a44
products:
  - Analytics SAQL Developer Guide
  - analytics
---

# 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()](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/reference/bi-saql-functions-todate.md) function.

```nolang
q = foreach q generate toDateOnly('CloseDate',"yyyy/MM/dd") as DateTime;
```
