Skip to content

DateTime handling

Oleg V. Kozlyuk edited this page Sep 14, 2022 · 4 revisions

ClickHouse.Client tries to correctly handle timezones and DateTime.Kind property. Specifically:

  • DateTime values are returned as UTC. User can then convert them themselves or use ToLocalTime() method on DateTime instance
  • When inserting, DateTime values are handled in following way:
    • UTC DateTimes are inserted 'as is', because ClickHouse stores them in UTC internally
    • Local DateTimes are converted to UTC according to user's local timezone settings
    • Unspecified DateTimes are considered to be in target column's timezone, and hence are converted to UTC according to that timezone
  • For columns without DateTime specified, client timezone is used by default (legacy behavior). UseServerTimezone flag in connection string can be used to use server timezone