Results 1 to 7 of 7
  1. #1
    Lounger
    Join Date
    Mar 2002
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date Math (Word XP)

    I have two fields, Date and Today. Each is set up as a form box, with the type set as date, and is bookmarked with the names Date and Today.

    How can I add or subtract these two fields? Nothing I do seems to come up with anything other than zero?

    Brett

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Date Math (Word XP)

    This is one of those arcane areas... it might be helpful to review the following threads:

    Field for today's date plus x days (95)

    Future Dates in Fields (2000)

    Then again, maybe not. <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15>

  3. #3
    Lounger
    Join Date
    Mar 2002
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date Math (Word XP)

    Thanks. This is good if I want to add or subtract a number of days to today's date, but doesn't seem to let me add or subtract two dates.

    Any other suggestions?

    Brett

  4. #4
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,048
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Date Math (Word XP)

    I suspect that even if you can do this with fields, it may be time to try VBA and a userform. Further, I suspect that the field contents are stored as text, regardless of the formatting applied through the field. I learned today that April Fool's day originated in France with the change from Julian to Gregorian calendars. Trying to deal with our arcane calendar with Word fields can make anyone feel like a fool. VBA has much better tools.

    The article How do I return the date of the previous month using VBA? may help you get started.
    Charles Kyle Kenyon
    Madison, Wisconsin

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Christchurch, New Zealand
    Posts
    250
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Date Math (Word XP)

    Hi Brett, what are you actually trying to achieve? Subtracting one date from another will give you a number of days between the two days. I can't work out why you would add two dates together (1 April 2002 plus 5 April 2002??)

    There are two functions that I've used in VBA - DateDiff and DateAdd. May be one of these is what you are looking for?

    DateDiff - Returns a Variant (Long) specifying the number of time intervals between two specified dates.

    DateAdd - Returns a Variant (Date) containing a date to which a specified time interval has been added

  6. #6
    Lounger
    Join Date
    Mar 2002
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date Math (Word XP)

    This looks as if it might be just what I need. One problem, though...where do I find info about the DateDiff command? There's nothing in the Word help file about it.

    Brett

  7. #7
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Christchurch, New Zealand
    Posts
    250
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Date Math (Word XP)

    It's actually a command in VB. If you go to the VB Editor - Alt F11 - and then select help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •