The datatype parameter lets you specify the type of time or date data in your database table that you are supplying to your dimension, dimension_group, filter, or measure field. Matching the data type to your field can increase query performance.
For dimensions, filters, and measures that contain date or time data, and for dimension groups with type: time, the datatype parameter applies to the sql parameter of the dimension group.
For dimension groups with type: duration, the datatype parameter applies to both the sql_start and sql_end parameters, so be sure the sql_start and sql_end are both of the specified data type.
The datatype parameter accepts the following values:
epoch - a SQL epoch field (i.e., an integer representing the number of seconds from the Unix epoch)
date - a SQL date field (i.e., one that does not contain time of day information)
datetime - a SQL datetime field
timestamp - a SQL timestamp field
yyyymmdd - a SQL field that contains an integer that represents a date of the form YYYYMMDD
The default value for datatype is timestamp.
Example
Create a dimension_group for a date field. Set the datatype: to date to increase query performance.
dimension_group: order_date
type: time
timeframes: [date, week, month, year]
datatype: date
sql: ${TABLE}.order_date
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-22 UTC."],[],[],null,["# datatype\n\n\u003cbr /\u003e\n\nUsage\n-----\n\n```\nview: view_name {\n dimension: order_date {\n datatype: date\n }\n}\n```\n\nDefinition\n----------\n\nThe `datatype` parameter lets you specify the type of time or date data in your database table that you are supplying to your [dimension](/looker/docs/2506/reference/param-field-dimension), [dimension_group](/looker/docs/2506/reference/param-field-dimension-group), [filter](/looker/docs/2506/reference/param-field-filter), or [measure](/looker/docs/2506/reference/param-measure-types) field. Matching the data type to your field can increase query performance.\n\nFor dimensions, filters, and measures that contain date or time data, and for dimension groups with [`type: time`](/looker/docs/2506/reference/param-field-dimension-group#type_time), the `datatype` parameter applies to the [`sql`](/looker/docs/2506/reference/param-field-sql) parameter of the dimension group.\n\nFor dimension groups with [`type: duration`](/looker/docs/2506/reference/param-field-dimension-group#type_duration), the `datatype` parameter applies to both the [`sql_start`](/looker/docs/2506/reference/param-field-dimension-group#sql_start) and [`sql_end`](/looker/docs/2506/reference/param-field-dimension-group#sql_end) parameters, so be sure the `sql_start` and `sql_end` are both of the specified data type.\n\nThe `datatype` parameter accepts the following values:\n\n- `epoch` - a SQL epoch field (i.e., an integer representing the number of seconds from the Unix epoch)\n- `date` - a SQL date field (i.e., one that does not contain time of day information)\n- `datetime` - a SQL datetime field\n- `timestamp` - a SQL timestamp field\n- `yyyymmdd` - a SQL field that contains an integer that represents a date of the form **YYYYMMDD**\n\nThe default value for `datatype` is `timestamp`.\n\nExample\n-------\n\nCreate a [`dimension_group`](/looker/docs/2506/reference/param-field-dimension-group) for a date field. Set the `datatype:` to `date` to increase query performance. \n\n dimension_group: order_date\n type: time\n timeframes: [date, week, month, year]\n datatype: date\n sql: ${TABLE}.order_date"]]