Ian, I don't know exactly what you are trying to do, but I fooled around with date arithmetic before. I wanted to determine what the date was six weeks from now, list the dates of every other Wednesday for the year (paydays for me) and put them into my reminder program, or list all the 5th Saturdays of the month for the year (certain social events). Maybe you alread looked at this and it didn't work for your program, but if you read about the longdatetoseconds and secondstolongdate toolbox functions (not sure of exact names right now), you can modify the fields of the long date record, convert it to seconds, then convert it back and it will give you the correct date info. For example, you can add a number to the day of the month, even go past 30 or 31 days, and when you convert it to seconds then back to a date, the long date record will be filled with the correct info. Maybe this will help you. Larry T > From: Ian Mann <i.mann@...> > Reply-To: futurebasic@... > Date: Fri, 15 Nov 2002 11:45:45 +0000 > To: futurebasic@... > Subject: Re: [FB] Date Arithmetic > > I have been fooling about with dates, and offer the below for peer > review.... > > > > begin globals > dim myDate as LongDateRec > dim mySeconds as SInt64 > dim Rect0 as Rect > dim Count as short > _YearSecs = 31557600 > _TenYearSecs = 315569088'315576000 (365.242 or 365.25 days per year) > _TwentyYearSecs = 631138176'631152000 > end globals > > > clear local > dim aSInt64 as SInt64 > dim OldSign as short > local fn AddLongToSInt64 (AddLong as Long, LSAddr as long) > blockmove LSAddr,@aSInt64,sizeof(SInt64) > OldSign = sgn(aSInt64.LoLong) > aSInt64.LoLong = aSInt64.LoLong + AddLong > long if AddLong > 0 > long if OldSign <> sgn(aSInt64.LoLong) > long if OldSign = -1 > inc(aSInt64.HiLong) > end if > end if > xelse > long if OldSign <> sgn(aSInt64.LoLong) > long if OldSign = 1 > dec(aSInt64.HiLong) > end if > end if > end if > blockmove @aSInt64,LSAddr,sizeof(SInt64) > end fn > > clear local > dim aDate as LongDateRec > dim xSeconds as SInt64 > local fn AddSecondsToLongDate (Seconds as Long, LDRAddr as long) > blockmove LDRAddr,@aDate,sizeof(LongDateRec) > longdatetoseconds (@aDate,@xSeconds) > fn AddLongToSInt64 (Seconds, @xSeconds) > longsecondstodate (@xSeconds,@aDate) > blockmove @aDate,LDRAddr,sizeof(LongDateRec) > end fn > > > clear local > dim aDate as LongDateRec > dim xSeconds as SInt64 > dim as str255 pDate,pTime > local fn PrintLongDate (LDRAddr as long) > blockmove LDRAddr,@aDate,sizeof(LongDateRec) > longdatetoseconds (@aDate,@xSeconds) > LongDateString( xSeconds, _longDate, pDate, 0 ) > LongTimeString( xSeconds, _longDate, pTime, 0 ) > print pTime,pDate,xSeconds.HiLong,xSeconds.LoLong > end fn > > clear local > dim xSeconds as SInt64 > dim as str255 pDate,pTime > local fn PrintSeconds64 (LSAddr as long) > blockmove LSAddr,@xSeconds,sizeof(SInt64) > LongDateString( xSeconds, _longDate, pDate, 0 ) > LongTimeString( xSeconds, _longDate, pTime, 0 ) > print pTime,pDate,xSeconds.HiLong,xSeconds.LoLong > end fn > > mySeconds.loLong = _maxLong > longsecondstodate (@mySeconds,@myDate) > setrect(Rect0,0,0,600,600) > window #1,"Dates",@Rect0 > fn PrintLongDate (@myDate) > > for Count = 1 to 40 > fn AddSecondsToLongDate (_TwentyYearSecs, @myDate) > fn PrintLongDate (@myDate) > next > > do > handleevents > until gFBQuit > > > -- > To unsubscribe, send ANY message to <futurebasic-unsubscribe@...> >