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

BQ datetime_trunc #58

Open
tiboun opened this issue Dec 3, 2024 · 1 comment
Open

BQ datetime_trunc #58

tiboun opened this issue Dec 3, 2024 · 1 comment

Comments

@tiboun
Copy link
Contributor

tiboun commented Dec 3, 2024

Translating

SELECT
    DATETIME '2008-12-25 15:30:00' as original,
        DATETIME_TRUNC(DATETIME '2008-12-25 15:30:00', DAY) as truncated;

returns

SELECT DATETIME '2008-12-25 15:30:00' AS original, DATE_TRUNC('DAY', DATETIME '2008-12-25 15:30:00') AS truncated

which results as a date once date_trunc is applied. date_trunc returns either a timestamp or a date depending on the granularity provided. Maybe we should transform it to a datetime once done if bigquery function is datetime_trunc

SELECT DATETIME '2008-12-25 15:30:00' AS original, DATE_TRUNC('DAY', DATETIME '2008-12-25 15:30:00')::DATETIME AS truncated
@tiboun
Copy link
Contributor Author

tiboun commented Dec 3, 2024

This applies as well to timestamp_trunc.

@tiboun tiboun changed the title BQ timestamp trunc BQ datetime_trunc Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant