Date Filter CASTING

  • 30 June 2022
  • 1 reply

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.




Edit: Found and am currently looking at it

This topic has been closed for comments

1 reply

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?