Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Location
    Lexington, KY
    Posts
    7

    Question Unanswered: Date suffix dilemma

    I'm exporting dates to a template in Word where the format needs to include a suffix--"st" on 1st, "nd" on 2nd, etc. The code below works for everything but the first three days of the month: 01, 02 and 03. I tried to remove the zeros and that didn't resolve the problem. Any ideas on how to fix this?

    WordObj.ActiveDocument.Bookmarks("FirstMoPay").Sel ect
    Me![FirstMoPay].SetFocus
    Dim day As Variant
    day = Mid([FirstMoPay].Text, 3, 2)
    Select Case day
    Case "01", "21", "31"
    day = day + "st"
    Case "02", "22"
    day = day + "nd"
    Case "03", "23"
    day = day + "rd"
    Case Else
    day = day + "th"
    End Select
    WordObj.Selection.TypeText day

  2. #2
    Join Date
    Jan 2004
    Posts
    184

    Re: Date suffix dilemma

    Try making the day a string instead of a variant, or make them integers if you don't want the extra '0'
    In abundance of water only the fool is thirsty. Bob Marley.

  3. #3
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Question Re: Date suffix dilemma

    Originally posted by Needshaircut
    I'm exporting dates to a template in Word where the format needs to include a suffix--"st" on 1st, "nd" on 2nd, etc. The code below works for everything but the first three days of the month: 01, 02 and 03. I tried to remove the zeros and that didn't resolve the problem. Any ideas on how to fix this?

    WordObj.ActiveDocument.Bookmarks("FirstMoPay").Sel ect
    Me![FirstMoPay].SetFocus
    Dim day As Variant
    day = Mid([FirstMoPay].Text, 3, 2)
    Select Case day
    Case "01", "21", "31"
    day = day + "st"
    Case "02", "22"
    day = day + "nd"
    Case "03", "23"
    day = day + "rd"
    Case Else
    day = day + "th"
    End Select
    WordObj.Selection.TypeText day
    What's the FirstMoPay formatted like originally?

    What does day evaluate to for the first three days?

    Is it producing a result for the first three days that is wrong or is it just not seeing those days?
    Gregg


    DAO, ADO, SQL, Automation and anything else I can pick up.

  4. #4
    Join Date
    Mar 2004
    Location
    Lexington, KY
    Posts
    7

    Re: Date suffix dilemma

    Originally posted by rami.haddad
    Try making the day a string instead of a variant, or make them integers if you don't want the extra '0'
    My word document still returns "1/th"?!

  5. #5
    Join Date
    Mar 2004
    Location
    Lexington, KY
    Posts
    7

    Re: Date suffix dilemma

    Originally posted by basicmek
    What's the FirstMoPay formatted like originally?

    What does day evaluate to for the first three days?

    Is it producing a result for the first three days that is wrong or is it just not seeing those days?
    FirstMoPay is formatted as short date. Day 1 returns "1/th".

Posting Permissions

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