最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

infopath - How to add years to year part of date field? - Stack Overflow

programmeradmin1浏览0评论

I have two date fields, when a user enters a date in datefield1 (dd/MM/YYY) eg 20/11/2024 I want the date in datefield2 to add 3 years to that date and show 20/11/202027. I have tried dateAdd(StartDate, "M", 36) but date add isn't a valid function

I have two date fields, when a user enters a date in datefield1 (dd/MM/YYY) eg 20/11/2024 I want the date in datefield2 to add 3 years to that date and show 20/11/202027. I have tried dateAdd(StartDate, "M", 36) but date add isn't a valid function

Share Improve this question edited Nov 20, 2024 at 11:37 Yevhen Horbunkov 15.6k3 gold badges26 silver badges45 bronze badges asked Nov 20, 2024 at 11:25 sql2015sql2015 6113 gold badges17 silver badges36 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You're on the right track. Adding years is this format:

datefield1.AddYears(3) 

It's a blind add of 3 years though & has caused me some issues in the past with accuracy I needed.

Keep leap years in mind because 2/29/2024 + 3 years won't give the same date.

发布评论

评论列表(0)

  1. 暂无评论