案例陈述:WHEN 日期距当前日期超过 90 年 THEN 最大日期距当前日期 90 年
我有一个包含人们生日的日期列。其中一些包含 90 多年前的日期,我希望这些日期的上限为 90 年前。
示例
current desired
1930-01-01 1932-01-01
1930-02-11 1932-02-11
正如您所看到的,如果出生日期自然超过 90 年前,则期望的状态是使出生日期距当前日期 90 年。
I have a date column that contains people's birthdays. Some of them contain dates that are over 90 years ago and I want those to be capped at 90 years ago.
Example
current desired
1930-01-01 1932-01-01
1930-02-11 1932-02-11
As you can see the desired state is to have the birthdate be 90 years from current date if it is naturally over 90 years ago.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这比我最初猜到的要棘手,而且可以更简单地写下,因为似乎有“竞争”,尽管它是易于阅读的,而是“
90年以上的无日期:
在90年前(又名标题)之前的一年(标题)版本:
唯一的案例:
因此,正如案例语句的背景下所要求的那样,我再次写了它(并修复了一年的部分),但也将其解构为解构,因此可以看到逻辑:
给予:给予:
it's more tricky than I initially guessed, and it can be written more simpler, now that there seems "be competition", albeit, this is less readable, than it was"
The no date over 90 years version:
The no year prior to the 90 years ago (aka the title) version:
Only sing CASE:
So as it was asked for in the context of CASE statements, I have written it again (and fixed the year partials) but also left it deconstructed, so the logic can be seen:
gives:
肯定很棘手。我什至在timeanddate.com上检查了最大90年的日期差异 - 看起来还不错。如果有人在此发现问题,请感谢反馈。
It was sure tricky one. I even checked date diff for 90 years max at timeanddate.com - looks ok. Do appreciate feedback if anyone finds issue in this.