Jump to content

This topic is 8374 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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.

Posted

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 ]

Posted

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.

Posted

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

Posted

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.

Posted

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

  • 2 weeks later...
Posted

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 ]

This topic is 8374 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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