简体   繁体   中英

How to find time difference in minutes in SQL in Snowflake

Here is a brief and simplified extract of my current dataset:

在此处输入图像描述

All my users currently have a start time and end time for various actions they complete. My time stamps are down to the milisecond. I however just want the time difference in minutes (not down to the milisecond).

Any idea how to achieve this in SQL in Snowflake?

Thanks!

Please check the DATEDIFF function: https://docs.snowflake.com/en/sql-reference/functions/datediff.html

For instance, the following returns 15 .

SELECT DateDiff(minute, '2021-01-01 17:08:27.890'::timestamp, 
                        '2021-01-01 17:23:23.990'::timestamp) 
               AS diff_minutes;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM