Results 1 to 6 of 6
  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Comparing Date Fields

    I need to create a fiscal year field in Word 97 that accomplishes in Word what the following statement accomplished in English:

    If today's month and day are less than or equal to June 30, display the current year, else display current year + 1.

    I'm pretty weak on field syntax. Can anyone help. Thanks.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Comparing Date Fields

    Do you mean a cell formula or VBA?

    Cell formula:
    =IF(MONTH(NOW())<7,YEAR(NOW()),YEAR(NOW()) +1)

    VBA:
    Dim iYear As Integer
    iYear = Year(Now)
    If Month(Now()) >= 7 Then
    iYear = iYear + 1
    End If
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Comparing Date Fields

    I mean field, a Word field. You know, Insert>Field. Thanks for your response, Geoff!
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

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

    Re: Comparing Date Fields

    Kevin,

    This is a matter of field calculations rather than VBA. I think the following will do it:
    { IF { DATE @ "MM" }<"07" { DATE " "yy" } { = { DATE @ "yy" }+1 # "00" } }
    Remember that you can't type in the braces but rather have to use Ctrl-F9 to insert fields.
    Take a look at http://www.addbalance.com/word/datefields2.htm. It may tell you more than you want to know about date calculations.

    Thank you for the interesting challenge. I will be adding it to my web pages.
    Charles Kyle Kenyon
    Madison, Wisconsin

  5. #5
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Comparing Date Fields

    I see from the Word forum that this solved the problem.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Comparing Date Fields

    Geoff,

    Correct. I forgot to get back over here and indicate that this puppy is fini.

    Thanks.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

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