Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

I have a field with a date. I want to create another field with the same date plus 1 year.

Thanks Again

Andy shocked.gif

How about:

Date(Month(myDate), Day(myDate), Year(myDate) + 1)

But what about Feb. 29?

Case(Month(myDate) = 2 and Day(myDate) = 29, Date(2, 28, Year(myDate) + 1), Date(Month(myDate), Day(myDate), Year(myDate) + 1) )

... but then again, (myDate + 365) ought to do it.

  • Author

I used "my date + 365" it worked.

Thanks

Andy cool.gif

This won't adjust for leap years.

Do it the easy way, and let FMP work out the hard stuff:

Date (Month (mydate), Day (mydate), Year (mydate) + 1)

Mind you, all the problems we have with date calculations is that they aren't metric: definately not designed for computers. Not even designed for humans either. For instance, a year is not a whole number of days -- the leap year thing is a kludge to get around this problem; months are not equal in length and there is no sensible pattern; etc.

When we say "date plus 1 year" most people understand it as the same day and month in the next year. If the original day was Feb 29, most people assume April 1 next year. The calculation "date + 365 days" will be wrong about 25% of the time.

For all I know these conventions might even differ between cultures.

[ March 26, 2002, 01:40 PM: Message edited by: Vaughan ]

quote:

Originally posted by Vaughan:

If the original day was Feb 29, most people assume April 1 next year.

Really? Gee, skip March? shocked.gif

Hey, Andy H has 2 more years before he has to worry about leap years, and by then he'll have moved on to bigger and better things, and it will be someone else's problem. Bwahahah.

This just in... a leap year occurs in all years divisible by 400 or, evenly divisible by 4 and not evenly divisible by 100.

Back to our regularly scheduled programming... it's true, you probably shouldn't use the date+365, unless you don't care about being off by a day now and then. So use the first formula I gave you if you want Feb. 29 to calculate to March 1 next year. Use the formula with the Case function if you want it to be Feb. 28.

Fitch,

Is the last part of your Leap year rule correct?

2000 was a leap year, 1900 was not, 2100 will not be. For whole 100 years, the "hundreds" component has to be evenly divisible by 4 for it to be a leap year.

Leap years are important to me. I only get birthday presents every 4 years as it is - so I don't need a database taking them away from me.

Of course, by 2100, some chunk of rock will have slowed the Earth's orbit down and we'll need a new calc. I hear that FMP v 84.0.7 will allow for this.

Russ Baker

Hey, don't blame me, blame the pope !

GregorXIII.jpg

(Gregory XIII, that is.)

PS: I enjoyed Questioning the Millennium by Stephen Jay Gould, check it out.

Dan -- Thanks for catching that! I should have wirtten March 1.

  • 2 weeks later...

quote:

Originally posted by Andy H:

I have a field with a date. I want to create another field with the same date plus 1 year.

Thanks Again

Andy
shocked.gif

yes I know it's old one but I couldn't resist:

So if anybody read again this topic...

code:


nextYear=Date(Month(Status(CurrentDate))+12,Day(Status(CurrentDate)),Year(Status(CurrentDate)))

or

nextYear=Date(Month(Status(CurrentDate)),Day(Status(CurrentDate)),Year(Status(CurrentDate))+1)

prevYear=Date(Month(Status(CurrentDate))-12,Day(Status(CurrentDate)),Year(Status(CurrentDate)))

or

prevYear=Date(Month(Status(CurrentDate)),Day(Status(CurrentDate)),Year(Status(CurrentDate))-1)

nextNYear=Date(Month(Status(CurrentDate))+12*n,Day(Status(CurrentDate)),Year(Status(CurrentDate)))

or

nextNYear=Date(Month(Status(CurrentDate)),Day(Status(CurrentDate)),Year(Status(CurrentDate))+n)

prevNYear=Date(Month(Status(CurrentDate))-12*n,Day(Status(CurrentDate)),Year(Status(CurrentDate)))

or

prevNYear=Date(Month(Status(CurrentDate)),Day(Status(CurrentDate)),Year(Status(CurrentDate))-n)

lastDateOfPrewMonth=Date(Month(Status(CurrentDate)),0,Year(Status(CurrentDate)))

And of course for february 29 use correctorCalc

correctForNonExisistingDay

If(Day(StartDate)!=Day(EndDate),

Date(Month(EndDate),0,Year(EndDate)),

EndDate)

HTH

Dj

[ April 05, 2002, 02:57 AM: Message edited by: dj ]

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.