Consulting

Results 1 to 3 of 3

Thread: Convert Short Date to Long Date

  1. #1
    VBAX Regular
    Joined
    Jul 2014
    Posts
    54
    Location

    Convert Short Date to Long Date

    Hi all

    This is hopefully a really simple thing, but I've hit a stumbling block in trying to puzzle it out.

    I have a ComboBox on a userform in Word, which is used as (1) the end date for calculation of interest (this bit works perfectly) and (2) dating the letter.

    For calculation of the interest, the date needs to be entered in format:- "dd/mm/yyyy", however when dating the letter it needs to display in long form, i.e. "Day Month Year".

    I have attempted to define DateofLetter as String, and then put the following into the code controlling the commandbutton to run the macro.

    DateofLetter = Format(Me.ComboBox3.Value, "Long Date")
    However that doesn't seem to work.

    Does anyone know how to go about converting the short date into long date?

    Thanks very much

    Dav

  2. #2
    VBAX Regular
    Joined
    Jul 2014
    Posts
    54
    Location
    Ah ha! Success - rather than code the conversion in VBA, I just changed the formatting of the DocVariable that displays it in the document. Problem solved!

  3. #3
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,411
    Location
    Sub ScratchMacro()
    'A basic Word macro coded by Greg Maxey
    Dim oDate As Date, strDate As String
      oDate = "1/20/2016"
      strDate = Format(oDate, "long date")
    lbl_Exit:
      Exit Sub
    End Sub
    Greg

    Visit my website: http://gregmaxey.com

Posting Permissions

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