pojin (ID: 1)
头衔:论坛坛主
等级:究级天王[荣誉]
积分:1301
发帖:99 篇
来自:保密
注册:2022-08-28 23:20:57
造访:2025-03-23 21:18:24
发帖:99 篇
来自:保密
注册:2022-08-28 23:20:57
造访:2025-03-23 21:18:24
[ 第 1 楼 ]
回复

SELECT
DATEDIFF(month,'2021-05-16 18:00:00',getdate())*1.0/12 as '年差值' ,
cast(DATEDIFF(month,'2021-04-16 18:00:00',getdate())*1.0/12 as decimal(18,1)) as '年差值-保留小数位',
DATEDIFF(Hour,'2022-05-16 18:00:00',getdate())*1.0/24 as '天差值' ,
cast(DATEDIFF(Hour,'2022-04-16 18:00:00',getdate())*1.0/24 as decimal(18,1)) as '天差值-保留小数位',
DATEDIFF(MINUTE,'2022-05-16 18:00:00',getdate())*1.0/60 as '小时差值' ,
cast(DATEDIFF(MINUTE,'2022-05-16 18:00:00',getdate())*1.0/60 as decimal(18,1)) as '小时差值-保留小数位'
DATEDIFF(month,'2021-05-16 18:00:00',getdate())*1.0/12 as '年差值' ,
cast(DATEDIFF(month,'2021-04-16 18:00:00',getdate())*1.0/12 as decimal(18,1)) as '年差值-保留小数位',
DATEDIFF(Hour,'2022-05-16 18:00:00',getdate())*1.0/24 as '天差值' ,
cast(DATEDIFF(Hour,'2022-04-16 18:00:00',getdate())*1.0/24 as decimal(18,1)) as '天差值-保留小数位',
DATEDIFF(MINUTE,'2022-05-16 18:00:00',getdate())*1.0/60 as '小时差值' ,
cast(DATEDIFF(MINUTE,'2022-05-16 18:00:00',getdate())*1.0/60 as decimal(18,1)) as '小时差值-保留小数位'

