chizuoka Posted May 16, 2012 Posted May 16, 2012 Hi everyone... got a simple yet no so simple question... what would be the script to add a year minus one day to a date? Like in insurance policies which expire one year less a day from the day you bought it? Seems complex because some months have 31 days.. some 30, some 29 on leap years n 28 on other.... Thanks!
No_access Posted May 16, 2012 Posted May 16, 2012 CAN YOU JUST ADD 364 DAYS...?? Please show your script so we can help you..
IdealData Posted May 16, 2012 Posted May 16, 2012 Actually, adding 364 days is not the answer due to leap years. Try adding: Date ( Month ( StartDate ) ) ; Day ( StartDate ) ; Year ( StartDate ) ) -1 where: StartDate is the start of the policy.
LaRetta Posted May 16, 2012 Posted May 16, 2012 Small change - you forgot to add one year. :^) Date ( Month ( StartDate ) ; Day ( StartDate ) ; Year ( StartDate ) + 1 ) -1 1
No_access Posted May 16, 2012 Posted May 16, 2012 OK, revision, this seems to work, let me know.. Case( Day ( startdate-1 ) >Day ( startdate ) ; Date ( Month ( startdate )-1 ; Day ( startdate-1 ) ; Year ( startdate ) +1); Day ( startdate-1 ) < Day ( startdate );Date ( Month ( startdate ) ; Day ( startdate-1 ) ; Year ( startdate ) +1))
Lee Smith Posted May 16, 2012 Posted May 16, 2012 You missed adding a year and you have an extra ) after month Date ( Month ( AnyDate ) ; Day ( AnyDate ) ; Year ( AnyDate ) + 1) -1 update, must be a slow day around the offices. LOL :giggle2: 1
Lee Smith Posted May 16, 2012 Posted May 16, 2012 Automatic message This topic has been moved from "Database Schema & Business Logic → Managing Scripts" to "Database Schema & Business Logic → Calculation Engine (Define Fields)".
Recommended Posts
This topic is 4914 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now