计算员工从加入日期到当前日期的工作经验 [英] calculate the work experience of employee from Joining date to Current Date

查看:78
本文介绍了计算员工从加入日期到当前日期的工作经验的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Sql Server 2005从加入日期到当前日期计算员工的工作经验



我的加入日期的列名是jDate,我需要减去加入到当前日期的区别。



请帮助。

谢谢。

How to calculate the work experience of employee from Joining date to Current Date using Sql Server 2005

My column name for joining date is jDate, I need to Minus the difference from Joining to Current Date.

Please help.
Thanks.

推荐答案

SELECT
    EMPLOYEEID, EMPLOYEENAME,

    convert(varchar(3),DATEDIFF(MONTH, jDate, GETDATE())/12) +' years '+
    convert(varchar(2),DATEDIFF(MONTH, jDate, GETDATE()) % 12)+ ' months'
    AS EXPERIENCE,


FROM EMPLOYEE


看看这个



TSQL Datediff [ ^ ]



我修改了该页面上的查询,这个显示了天数,但如果你看一下文章您将看到有许多不同的选项可用于衡量日期之间的差异。



Have a look at this

TSQL Datediff[^]

I have modified the query on that page, this one shows the number of days, but if you look at the article you will see there are many different options that you can use to measure the difference between the dates.

USE AdventureWorks;
GO
SELECT DATEDIFF(day, jDate, GETDATE()) AS NumberOfDays
FROM YourTableName;
GO


这篇关于计算员工从加入日期到当前日期的工作经验的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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