Date Filter CASTING

CJC
New Member

Very new to Looker.  What determines the internals behind how Looker converts a filter to a datetime?  For example, I have a field that’s setup in Looker as follows:

dimension_group: some_start_date {
type: time
timeframes:[time, hour_of_day, date, week, day_of_week, month, month_name, quarter, year]
sql: ${TABLE}.some_start_date ;;
}

When I pull this field in and look at the generated SQL, it is converted to:

DATEPART(hh, CAST(schema.some_start_date  AS DATETIME))

The table field is a DATETIME2, so there are some errors that occur when the cast to a DATETIME happens.  Looking to better understand how this works in the backend so I can implement a fix.  Have been reading the documentation on this and haven’t found exactly what I’m looking for yet, and was hoping someone could point me in the right direction of things to research.

Thanks!

Edit: Found https://docs.looker.com/data-modeling/learning-lookml/how-looker-generates-sql and am currently looking at it

0 1 259
1 REPLY 1

CJC
New Member

To add to the above as I can no longer edit the original message - what is causing Looker to convert this to a DATETIME instead of a DATETIME2?  Is there a minimum Looker version that supports Datetime2?  

Top Labels in this Space
Top Solution Authors