+ Reply to Thread
Results 1 to 4 of 4

Date Problem - DPART

  1. #1
    Forum Contributor mccrimmon's Avatar
    Join Date
    02-19-2004
    Location
    Scotland
    MS-Off Ver
    2003
    Posts
    249

    Date Problem - DPART

    Hi

    Im hoping someone can help.

    I have the following code, however, I am getting an unexpected result.

    FullDate is coming in as a string value of 40716.
    When converted using the CDate function it is correctly showing as 22nd June 2011.

    However, the problem seems to be with strDateMonth. This is showing as Jan rather than June when going through the format?

    Can anyone help?

    Seems bizarre.

    Please Login or Register  to view this content.
    Thanks

    McC
    McCrimmon

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Date Problem - DPART

    the problem is in Format function, this works as it should:
    Please Login or Register  to view this content.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Date Problem - DPART

    Hello McCrimmon,

    The problem lies with how "DartPart" returns the month. It does not return the month name as "Jun", "Jul", etc, but as a number. January is 1, February is 2, etc. You can skip using the "DatePart" for the month and use just the format statement. You can then format the month as the short or long form.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Date Problem - DPART

    Why not using VBA ?

    Please Login or Register  to view this content.



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1