Announcement

Collapse
No announcement yet.

Going 28 days backwards

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Going 28 days backwards

    Is there an easy formula to subtract days from a date to arrive
    at a new date?
    I.e. Y$ = 2002-Dec-30

    NewDate$ = Y$-28 days
    NewDate$ = 2002-Dec-02

    Over simplistic, but my formula fails when subtracting 28 days
    goes back into the previous month.

    If anyone knows where I can get date formulas for use in Basic,
    please send them to me or send the URL. Date computation has
    gotten to be important to me in genealogy.

    Thank you.

    Robert


    ------------------

  • #2
    The easiest way is to convert the current date to Julian Days, subtract 28, then convert back to a normal date format.

    In fact, if you look in DATEUNIT.BAS in your PB/DOS install, you'll find a function called DateMath()... it uses two other functions (DateToDays() and DaysToDate()) to add/subtract days to obtain the target date.

    I hope this helps!

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      That DOES help, except for one thing. Is there any easy way to get around the year limitations? Not all my dates fall between the 4 year different dates. I have gone back to 1630. I am aware of the differences in Julian - Gregorian calendar systems, but as a rule I try to keep everything in Gregorian format.

      Thank you.

      ------------------

      Comment


      • #4
        According to the notes in those routines, they work back to 01-01-1900 only.

        If you want code that deals with a wider range of years, then search the Source Code forum for "julian".


        ------------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment

        Working...
        X