从员工表中的DOB计算退休日期 [英] Calculating Retirement Date from DOB in an Employee Table

查看:75
本文介绍了从员工表中的DOB计算退休日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果DOB是01.04.1960,则DOR(退休日期)将是31.03.2020。

否则,如果DOB是02.04.1960或该月的任何其他日期,DOR将是30.04.2020。

(退休原则= DOB + 60年)

If DOB is 01.04.1960, the DOR (date of retirement) would be 31.03.2020.
Else, if DOB is 02.04.1960 or any other date in the month, the DOR would be 30.04.2020.
(Retirement principle= DOB+60 years)

推荐答案

这很简单, DateAdd功能应该执行技巧。

DateAdd(间隔,数字,日期)


有一点需要注意:内部访问使用美国格式处理日期#MM / DD / YYYY#特别是在VBA中。通常,SQL和VBA引擎都正确处理国际格式;但是,如果您在函数返回正确日期时遇到问题,那么您可以尝试以美国格式明确设置日期(请注意#表示日期文字):
DateAdd(" Y",60,#04/01/1960#)
This is simple enough that the DateAdd Function should do the trick.

DateAdd ( interval, number, date )

One thing to note: Internally Access handles dates using the USA format #MM/DD/YYYY# especially in VBA. Usually, both the SQL and the VBA engines deal with the international formats correctly; however, if you have issues with the function returning the correct date then you might try explicitly setting the date in the USA format (note the "#" which indicates a date literal):
DateAdd("Y",60,#04/01/1960#)


别以为它就这么简单。


如果没有我对美国日期格式的完全不合逻辑的惯常咆哮,以及英国日期格式的不合逻辑性,我对理解Nityanda''的逻辑感到有点失落。问题。


他或她似乎说,如果DOB是本月的第一天,DOR是DOB + 59岁+ 361,362,363,364天(取决于在这个月)带你到上个月的最后一个日期。


另一方面,如果DOB是在本月的第一天之后,DOR是DOB + 60年+最多29天(取决于一个月中的天数)带你到月底。


那真的是ems不合逻辑。 OP可以在给出解决方案之前确认这是正确的。


Phil
Don''t think it is as simple as that.

Without my usual rant about the total illogicality of the US date format, and the somewhat less illogicality of the UK date format, I am at a bit of a loss to understand the logic of Nityanda''s question.

He or she seems to say that if the DOB was the first of the month, the DOR is DOB + 59 years + 361, 362, 363, 364 days (Depending on the month) to take you to the last date in the previous month.

On the other hand, if the DOB is after the first of the month, the DOR is DOB + 60 years + up to 29 days (depending on how many days in the month) to take you to the end of the month.

That really seems illogical. Can the OP confirm this is correct before giving a solution.

Phil


ZMBD:

有一点需要注意:内部访问使用美国格式#MM / DD / YYYY#处理日期,特别是在VBA中。
ZMBD:
One thing to note: Internally Access handles dates using the USA format #MM/DD/YYYY# especially in VBA.



和你一起回到学校。那是错的。只有SQL中的日期字符串可以被认为是以这种方式运行,但即便如此,这也不是100%,因为它只是SQL日期字符串的有效格式之一。请参阅文字日期时间及其分隔符(#)


VBA和数据库本身的数据在内部将日期存储为数字。这些数字通常反映已知开始日期的天数(及其部分时间)。在MS Office,日期是1899年12月30日。

Back to school with you. That''s just wrong. Only date strings in SQL could be considered to behave that way, but even then that isn''t 100% as that''s only one of the valid formats for a SQL date string. See Literal DateTimes and Their Delimiters (#).

VBA, and the data within the database itself, stores dates internally as numbers. These numbers typically reflect the number of days (and parts thereof for times) from a known starting date. In MS Office that date is 30 december 1899.


这篇关于从员工表中的DOB计算退休日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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