使用给定日期计算总天数 [英] To calculate total number of days using the given date

查看:114
本文介绍了使用给定日期计算总天数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想使用sql
计算总天数 我的要求是我已经使用这两个日期发布了日期和当前日期,我想计算总天数.

Hi
I want to calculate the total number of days using sql
My requirement is I have posted date and a current date using these two dates i want to calculate the total number of days

推荐答案

declare 
@startdate date,
@enddate date
set @enddate='20120901'--yyyymmdd'
set @startdate='20120316'--'yyyymmdd'
select @startdate ,@enddate 
,DATEDIFF(YY,@startdate,@enddate)'int.age in years'
,DATEDIFF(DD,@startdate,@enddate )'int.age in days'
,DATEDIFF(mm,@startdate,@enddate)'int.age in months'


^ ]

CP搜索 [ ^ ]
How to get difference between 2 date i.e. hire date and joining date[^]

CP Search[^]


HI,
检查此

Check this
declare @t1 nvarchar(10)
set @t1 ='1/1/2010'
declare @t2 nvarchar(10)
set @t2 ='1/3/2010'

select datediff(DAY,convert(datetime, convert(char(10), @t1,110)),convert(datetime, convert(char(10),@t2, 110)))



最好的问候
米特瓦里(M.Mitwalli)



Best Regards
M.Mitwalli


这篇关于使用给定日期计算总天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆