I select date that 2019-07-05,but the date in sql that execute in database is 2019-07-04

image

select event_type,event_sub_type "sub_type",level,datetime from event_data where toDate(`default`.`event_data`.`date`) = '2019-07-04'  and level < 'error' order by datetime desc FORMAT TabSeparatedWithNamesAndTypes;

Hi @liwenhao
Which version of Metabase?
Which database are you connecting to?
So the date-selector is based on your browsers timezone, but that will get converted several times based on “Reporting Timezone” (Admin > Settings > General), the timezone of JVM that runs Metabase, and the timezone of your database.
Have a look at the troubleshooting guide:
https://www.metabase.com/docs/latest/troubleshooting-guide/timezones.html

the version is v0.32.9

Duser.timezone,Report Time Zone and the timezone of database is Asia/Taipei

the frontend log,it is correct,can you tell me the handle code of backend

{native: {template-tags: {,…},…}, type: "native", database: 35,…}
database: 35
native: {template-tags: {,…},…}
parameters: [{type: "date/single", target: ["dimension", ["template-tag", "date"]], value: "2019-07-06"}]
0: {type: "date/single", target: ["dimension", ["template-tag", "date"]], value: "2019-07-06"}
target: ["dimension", ["template-tag", "date"]]
type: "date/single"
value: "2019-07-06"
type: "native"

the response:

{"database_id":35,"started_at":"2019-07-05T01:43:30.993Z","json_query":{"native":{"template-tags":{"date":{"id":"101f8cd7-bfd3-260c-512a-3a3219a5cf7e","name":"date","display-name":"时间","type":"dimension","dimension":["field-id",982],"widget-type":"date/single","default":"past7days"},"event_type":{"id":"86fe9cbc-d79d-9b2b-0b5e-be75bde31c3e","name":"event_type","display-name":"事件类型","type":"dimension","dimension":["field-id",985],"widget-type":"category"}},"query":"select event_type,event_sub_type \"sub_type\",level,datetime,data,today()==date \"today\"\nfrom event_data\nwhere {{date}} and {{event_type}} and level < 'error'\norder by datetime desc"},"type":"native","database":35,"parameters":[{"type":"date/single","target":["dimension",["template-tag","date"]],"value":"2019-07-06"}],"async?":true,"middleware":{"add-default-userland-constraints?":true,"userland-query?":true},"constraints":{"max-results":10000,"max-results-bare-rows":2000}},"average_execution_time":null,"status":"completed","context":"ad-hoc","row_count":13,"running_time":24,"data":{"rows":[["git_code_collect","gen_branch_infos","info","2019-07-05T07:32:06.000+08:00","{\"info\": \"end\"}",1],["git_code_collect","gen_branch_infos","info","2019-07-05T02:32:17.000+08:00","{\"info\": \"start\"}",1],["git_code_collect","gen_commit_all_projects","info","2019-07-05T02:32:17.000+08:00","{\"info\": \"end\"}",1],["dataapi","daily/record","info","2019-07-05T02:03:04.000+08:00","{\"update_type\": \"DataApiUpdateHandle\", \"status\": \"complete\"}",1],["git_code_collect","gen_code_change_per_day","info","2019-07-05T02:02:11.000+08:00","{\"info\": \"end\"}",1],["git_code_collect","gen_commit_all_projects","info","2019-07-05T02:02:11.000+08:00","{\"info\": \"start\"}",1],["grapelog_collect","update","info","2019-07-05T02:01:43.000+08:00","{\"update_type\": \"collect_grapelog\", \"status\": \"start\"}",1],["corecd","update","info","2019-07-05T01:44:42.000+08:00","{\"update_type\": \"CoreCDUpdateHandle\", \"status\": \"complete\"}",1],["dataapi","daily/record","info","2019-07-05T01:44:42.000+08:00","{\"update_type\": \"DataApiUpdateHandle\", \"status\": \"start\"}",1],["dts_collect","update","info","2019-07-05T01:05:05.000+08:00","{\"update_type\": \"collect_dts\", \"status\": \"complete\"}",1],["dts_collect","update","info","2019-07-05T01:01:43.000+08:00","{\"update_type\": \"collect_dts\", \"status\": \"start\"}",1],["git_code_collect","gen_code_change_per_day","info","2019-07-05T01:00:38.000+08:00","{\"info\": \"start\"}",1],["corecd","update","info","2019-07-05T00:18:51.000+08:00","{\"update_type\": \"CoreCDUpdateHandle\", \"status\": \"start\"}",1]],"columns":["event_type","sub_type","level","datetime","data","today"],"native_form":{"template-tags":{"date":{"id":"101f8cd7-bfd3-260c-512a-3a3219a5cf7e","name":"date","display-name":"时间","type":"dimension","dimension":["field-id",982],"widget-type":"date/single","default":"past7days"},"event_type":{"id":"86fe9cbc-d79d-9b2b-0b5e-be75bde31c3e","name":"event_type","display-name":"事件类型","type":"dimension","dimension":["field-id",985],"widget-type":"category"}},"query":"select event_type,event_sub_type \"sub_type\",level,datetime,data,today()==date \"today\"\nfrom event_data\nwhere toDate(`default`.`event_data`.`date`) = '2019-07-05' and 1 = 1 and level < 'error'\norder by datetime desc","params":null},"cols":[{"name":"event_type","display_name":"Event Type","base_type":"type/Text","source":"native"},{"name":"sub_type","display_name":"Sub Type","base_type":"type/Text","source":"native"},{"name":"level","display_name":"Level","base_type":"type/Text","source":"native"},{"name":"datetime","display_name":"Date Time","base_type":"type/DateTime","source":"native"},{"name":"data","display_name":"Data","base_type":"type/Text","source":"native"},{"name":"today","display_name":"Today","base_type":"type/Integer","source":"native"}],"results_metadata":{"checksum":"e+CV5DPznpSV1PxAoBPXwQ==","columns":[{"name":"event_type","display_name":"Event Type","base_type":"type/Text","special_type":"type/Category","fingerprint":{"global":{"distinct-count":5,"nil%":0.0},"type":{"type/Text":{"percent-json":0.0,"percent-url":0.0,"percent-email":0.0,"average-length":12.307692307692308}}}},{"name":"sub_type","display_name":"Sub Type","base_type":"type/Text","special_type":"type/Category","fingerprint":{"global":{"distinct-count":5,"nil%":0.0},"type":{"type/Text":{"percent-json":0.0,"percent-url":0.0,"percent-email":0.0,"average-length":13.692307692307692}}}},{"name":"level","display_name":"Level","base_type":"type/Text","special_type":null,"fingerprint":{"global":{"distinct-count":1,"nil%":0.0},"type":{"type/Text":{"percent-json":0.0,"percent-url":0.0,"percent-email":0.0,"average-length":4.0}}}},{"name":"datetime","display_name":"Date Time","base_type":"type/DateTime","special_type":null,"fingerprint":{"global":{"distinct-count":10,"nil%":0.0},"type":{"type/DateTime":{"earliest":"2019-07-04T16:18:51.000Z","latest":"2019-07-04T23:32:06.000Z"}}}},{"name":"data","display_name":"Data","base_type":"type/Text","special_type":null,"fingerprint":{"global":{"distinct-count":9,"nil%":0.0},"type":{"type/Text":{"percent-json":1.0,"percent-url":0.0,"percent-email":0.0,"average-length":37.15384615384615}}}},{"name":"today","display_name":"Today","base_type":"type/Integer","special_type":null,"fingerprint":{"global":{"distinct-count":1,"nil%":0.0},"type":{"type/Number":{"min":1.0,"max":1.0,"avg":1.0,"sd":0.0,"q1":1.0,"q3":1.0}}}}]},"insights":null}}

@liwenhao Which database are you querying? I think most of backend logic is done by the the driver.

can you show me the entile process of timezone,because the timezone of Duser.timezone,Report Time Zone and database is the same

i use clickhouse,and the driver is https://github.com/enqueue/metabase-clickhouse-driver

@liwenhao I don’t understand your question, but I can see that we’ve been through this before Problem with today filter in dashboard and https://github.com/enqueue/metabase-clickhouse-driver/issues/19.
Since I don’t use ClickHouse, then I cannot help you.