Consulting

Results 1 to 3 of 3

Thread: Date Format

  1. #1

    Date Format

    Hi,

    I want to convert my date into the following format: from dd.01.2018 to --> January 2018

    Here is the code
    Dim strFormatted As String
    Dim Date1 As Date
    
    Date1 =Worksheets("Table1").Cells(1,1).Value       ' here is the date given as follows dd.01.2018
    
    strFormatted = Format(Expression:=Date1, Format:="mmm-yy")
    This code returns strFormatted as dd.mmm. I dont understand why?

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    If you actually have a valid date value in worksheet Table1 cell A1, then the format string would be:
    strFormatted = Format(Expression:=Date1, Format:="mmmm yyyy")

  3. #3
    Hi kenneth thank you.

Posting Permissions

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