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

9.3k Views Asked by At

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))

1

There are 1 best solutions below

0
On BEST ANSWER

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                                        |
----------------------------------------------------------------------+