Results 1 to 7 of 7
  1. #1
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    date mergefield (2000)

    I want to surpress any leading zero from the day in the date mergefield I'm using:
    { = { Mergefield Date @ "dd" } * ordinal } { Mergefield Date @ "MMMM, yyyy" }

    This will be OK for dates like 21st January, 2003 but will end up displaying 01st January, 2003.
    Is there a switch to surpress the leading zero?

    Also (and this is wishful thinking I feel [img]/forums/images/smilies/smile.gif[/img]) it would be nice if the "ordinal" appeared in superscript, like it does during ordinary typing. Is there a way? And what about pulling up the day of the week while I'm at it?
    Saturday, 4th January, 2003?

    thanks

    Alan

  2. #2
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: date mergefield (2000)

    <P ID="edit" class=small>(Edited by carbonnb on 03-Jan-03 09:43. Edited to correct a dumb typo
    )</P>{ MERGEFIELD Date @ "d" } will give you the date with no leading zero.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: date mergefield (2000)

    I can help with one of your requests <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    { Mergefield Date @ "dddd" } will give you the day of the week.

    StuartR

    And another
    Simple experiment shows that { Date @ "d" * ordinal } does suppress leading 0s

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: date mergefield (2000)

    The Word 2000 help for a date-time field includes the following...

    <big>Day (d)</big>
    Displays the day of the month or the day of the week. The letter "d" can be either uppercase or lowercase.

    <table border=1><td>Picture item</td><td>Displays the day of the month or week as</td><td>d</td><td>A number without a leading 0 (zero) for single-digit days. For example, the sixth day of the month is displayed as "6".</td><td>dd</td><td>A number with a leading 0 (zero) for single-digit days. For example, the sixth day of the month is displayed as "06".</td><td>ddd</td><td>A three-letter abbreviation. For example, Tuesday is displayed as "Tue".</td><td>dddd</td><td>The full name of the day of the week.</td></table>
    StuartR

  5. #5
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: date mergefield (2000)

    Thanks Stuart and Bryan. Quite silly on my part, in retrospect. I'd been working in an application that uses a "d" for a digit placeholder in formatted I/O, and had this stuck in my brain for some reason. Naturally, the day of month would therefore *have* to be "dd"... so I thought. Had I consulted the help file properly, I'd have found the answers - serves me right for starting on something new at such a late hour.

    cheers

    Alan

  6. #6
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: date mergefield (2000)

    No problem Alan, glad to help.

    We all have those brian-freeze days.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  7. #7
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: date mergefield (2000)

    Well, perhaps I can help with another, since I cocked up the query in the first place. I wrote some VBA to insert the date, with the day ordinal superscripted. Hopefully it will be useful to somebody, if only to have an expert reduce it down to 3 lines <img src=/S/wink.gif border=0 alt=wink width=15 height=15>

    <hr>Sub VerboseDate()
    '
    ' VerboseDate Macro -
    ' Inserts a date at the current insersion point, in the form:
    ' "The date is the 6th of January, 2003"
    ' with the date ordinal formatted in superscript.
    '
    Dim MyDay, MyOrdinal, showdate
    MyDay = Day(Date)

    Select Case MyDay
    Case 1, 21, 31
    'Debug.Print "LastDigit = 1"
    MyOrdinal = "st"
    Case 2, 22
    'Debug.Print "LastDigit = 2"
    MyOrdinal = "nd"
    Case 3, 23
    'Debug.Print "LastDigit = 3"
    MyOrdinal = "rd"
    Case Else ' Other values.
    'Debug.Print "LastDigit is a th"
    MyOrdinal = "th"
    End Select

    Selection.TypeText Text:="The date is the " & MyDay

    With Selection.Font
    .Superscript = True
    End With
    Selection.TypeText Text:=MyOrdinal
    With Selection.Font
    .Superscript = False
    End With

    Selection.InsertDateTime DateTimeFormat:=" of MMMM, yyyy", _
    InsertAsField:=False

    End Sub
    <hr>

    cheers

    Alan

Posting Permissions

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