Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date&Time improvements #9959

Closed
2 of 4 tasks
qoega opened this issue Mar 31, 2020 · 5 comments · Fixed by #22001
Closed
2 of 4 tasks

Date&Time improvements #9959

qoega opened this issue Mar 31, 2020 · 5 comments · Fixed by #22001
Labels
comp-datetime date & time & timezone related easy task Good for first contributors enhancement

Comments

@qoega
Copy link
Member

qoega commented Mar 31, 2020

  • Add getTimeZone function. Trivial, but can help user to answer question about timezone in all cases - toTypeName for DateTime without timezone does not answer this question and you need to read the docs
getTimeZone(now()) = timezone()
  • Add modifier in formatDateTime to print 'Time offsets from UTC' in following formats "+02:00","+0200", or "+02". Note: +00:00 should be printed with no offset.

  • Add parseDateTimeBestEffort description. At least describe arguments. Probably move out of type conversions.

  • dateDiff documentation is incomplete. Probably we should define function behavior more strictly.

@filimonov filimonov added the comp-datetime date & time & timezone related label Mar 31, 2020
@alexey-milovidov
Copy link
Member

Note: +00:00 should be printed with no offset.

ISO 8601 also allows Z.

@hhell
Copy link
Contributor

hhell commented May 7, 2020

getTimeZone

A bit of a hack, but it can be implemented by
if(toTypeName(val) like 'DateTime%(%', splitByChar('\'', toTypeName(val))[2], NULL))

Example:

select
    toDateTime(now(), 'Europe/Moscow') as val,
    if(
        toTypeName(val) = 'DateTime',
        timezone(),
        if(
            toTypeName(val) like 'DateTime%(%',
            splitByChar('\'', toTypeName(val))[2],
            NULL))
    as val_tz
format JSONCompact

@grundrauschen
Copy link

It would also be great to add a modifier to formatDateTime to print subsecond values when used in conjunction with DateTime64. Together with the timezone offset from above I would then be able to get a full ISO-8601 timestamp from DateTime64 like 2020-11-27T14:54:10.123456Z.

@alexey-milovidov
Copy link
Member

alexey-milovidov commented Mar 24, 2021

The function has been added under timezoneOf name.

@alexey-milovidov
Copy link
Member

Closing in favor of #40103.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-datetime date & time & timezone related easy task Good for first contributors enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants