Results 1 to 3 of 3
  1. #1
    3 Star Lounger MacroAlan's Avatar
    Join Date
    Feb 2003
    Location
    St Louis, Missouri, USA
    Posts
    254
    Thanks
    6
    Thanked 1 Time in 1 Post

    DatePart Function (XP / SP2)

    I am trying to extract the 2 digit month and day part from a date field using the DatePart("m",[FieldName]) function. My issue is that I need a 2-digit number for months 01 - 09. Changing the function to ..."mm",... returns #ERROR. Anyone know how to extract this?
    Alan

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DatePart Function (XP / SP2)

    DatePart returns a number (integer). What you want is a formatted string (month number with leading zero).

    For the month with a leading zero, use Format([FieldName],"mm")
    For the day with a leading zero, use Format([FieldName],"dd")

  3. #3
    3 Star Lounger MacroAlan's Avatar
    Join Date
    Feb 2003
    Location
    St Louis, Missouri, USA
    Posts
    254
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: DatePart Function (XP / SP2)

    Thanks! Looks like we are cookin
    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
  •