redhotkoi Posted March 26, 2002 Posted March 26, 2002 I have a field with a date. I want to create another field with the same date plus 1 year. Thanks Again Andy
Fitch Posted March 26, 2002 Posted March 26, 2002 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.
redhotkoi Posted March 26, 2002 Author Posted March 26, 2002 I used "my date + 365" it worked. Thanks Andy
Vaughan Posted March 26, 2002 Posted March 26, 2002 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 ]
danjacoby Posted March 26, 2002 Posted March 26, 2002 quote: Originally posted by Vaughan: If the original day was Feb 29, most people assume April 1 next year. Really? Gee, skip March?
Fitch Posted March 27, 2002 Posted March 27, 2002 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.
RussBaker Posted March 27, 2002 Posted March 27, 2002 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
Fitch Posted March 27, 2002 Posted March 27, 2002 Hey, don't blame me, blame the pope ! (Gregory XIII, that is.) PS: I enjoyed Questioning the Millennium by Stephen Jay Gould, check it out.
Vaughan Posted March 27, 2002 Posted March 27, 2002 Dan -- Thanks for catching that! I should have wirtten March 1.
djgogi Posted April 5, 2002 Posted April 5, 2002 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 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 ]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now