Results 1 to 6 of 6

Thread: [RESOLVED] formate in vba code

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Resolved [RESOLVED] formate in vba code

    how do i get this format for example June 7, 2010
    MyDate = Format(Now() + 7, "mm/dd/yy")

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Re: formate in vba code

    still it shows mm/dd/yy
    MyDate = Format(Now() + 7, "[$-409]mmmm d, yyyy;@")

  3. #3
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: formate in vba code

    Kam

    Maybe something like this:

    Code:
    z1 = Now                     ' 5/31/2010 1:45:32 PM
    z2 = Format(z1, "Long Date") ' Monday, May 31, 2010
    v1 = Instr(z1, ",")
    z3 = Mid(z1, v1 + 1)         ' May 31, 2010
    Is that what you're looking for?

    Spoo

  4. #4
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: formate in vba code

    You must declare MyDate as String (or Variant), not Date.
    Code:
        Dim MyDate As String
        
        MyDate = Format(Date + 7, "mmmm d, yyyy")
        Debug.Print MyDate '-->  June 8, 2010
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Re: [RESOLVED] formate in vba code

    thanks Anhn

  6. #6
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: [RESOLVED] formate in vba code

    Kam -- sorry, I completely missed your desire regarding the +7
    Anhn -- nice

    Spoo

Posting Permissions

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



Click Here to Expand Forum to Full Width