Snowflake SQL: How to add a time to a date to make a datetime?
Asked Answered
R

1

6

I have a date column and a time column and I'd like to make a datetime/timestamp.

I've tried

Date+Time

but I get:

SQL compilation error: error line 4 at position 14 Invalid argument types for function '+': (DATE, TIME(9))

Rewarding answered 7/11, 2018 at 12:25 Comment(2)
Can you specify which implementation of SQL this is using (mysql, postgres, SQL Server)?Azucenaazure
@Azucenaazure snowflake, as per tags.Rewarding
C
11

You can use TIMESTAMP_NTZ_FROM_PARTS(date, time), e.g.

select timestamp_ntz_from_parts('2013-04-05'::date, '01:02:03.12345'::time);
----------------------------------------------------------------------+
 TIMESTAMP_NTZ_FROM_PARTS('2013-04-05'::DATE, '01:02:03.12345'::TIME) |
----------------------------------------------------------------------+
 2013-04-05 01:02:03.123450000                                        |
----------------------------------------------------------------------+
Chaotic answered 8/11, 2018 at 6:8 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.