我有两列带时间戳。我试图在忽略小时和分钟的情况下找到仅 DAYS 的差异。
我在雪花中使用 SQL。
Ex :- I have both column values as following
Column1 value = 07-DEC-16 11.05.24.500000000
Column2 value = 08-DEC-16 03.12.06.874000000
我只想减去 DAYS 的两列,在本例中,自 12 月 8 日至 12 月 7 日 =1
最佳答案
Calculates the difference between two date, time, or timestamp expressions based on the date or time part requested. The function returns the result of subtracting the second argument from the third argument.
SELECT DATEDIFF(day, col1, col2)
FROM tab;
或者:SELECT ABS(DATEDIFF(day, col1, col2)) -- absolute value
FROM tab;
关于sql - 仅当列在时间戳中时如何才能找到 DAYS 的差异?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69573807/