Difference between two timestamp with all elements of dates

Viewed 25

I just wanted to subtract between two dates in Snowflake and get the output with all elements of dates.

For example:

I have two dates 2022-05-02 20:10:30.090 2021-04-01 10:05:20.080

And I want output as 10101100510010

Please let me know if there is any way of doing this in Snowflake. Thanks

1 Answers

I don't think the question does not make any sense, but if this is what you want:

I have two dates 2022-05-02 20:10:30.090 2021-04-01 10:05:20.080

And I want output as 10101100510010

Here is the solution:

select REGEXP_REPLACE( '2022-05-02 20:10:30.090', '[- :.]*', '')::NUMBER -
       REGEXP_REPLACE( '2021-04-01 10:05:20.080', '[- :.]*', '')::NUMBER as RESULT;

enter image description here

I would prefer something like this:

select timediff(milliseconds, '2021-04-01 10:05:20.080', '2022-05-02 20:10:30.090' );
Related