[英]SQL Select Subtract Date Time with Date Time
I have 2 different fields from a table and both have same format of timestamp. 我有一个表中的2个不同的字段,并且都具有相同的时间戳格式。
7/18/2012 10:19:48 AM
and 和
7/18/2012 10:20:46 AM
How can I subtract two timestamp to get the duration in time. 如何减去两个时间戳以及时获得持续时间。
SELECT (firstDateColumn - secondDateColumn) * 24 * 60 difference_in_minutes
FROM yourtable
If the dates are string then convert them first: 如果日期是字符串,则首先转换它们:
SELECT (TO_DATE(firstDateColumn, 'dd/mm/yyyy HH:MI:SS AM') -
TO_DATE(secondDateColumn, 'dd/mm/yyyy HH:MI:SS AM')) *
24 * 60 difference_in_minutes
FROM yourtable
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.