Date Formatting

  • I previously posted a thread about getting into an External object, which I finally figured out on my own, but when I pull the date off the system, it comes as 072205, which Excel interprets as sometime in 2089. Whats the easiest VB code to have this date changed around before I have it pasted into the cell in Excel? I'm running my macro from the other program and having it link to Excel, so not all Excel functions are available.

  • Re: Date Formatting

    if the date were say 1st July would your system return 070105 or 07105?

    presuming former - just convert your returned string to a date by manipulating the string itself rather than trying to convert direct to date


    Dim d As String
    d = "072205"  'this would be referenced to your variable and not hardcoded as it is here
    Dim d1 As Date
    d1 = CDate(Mid(d, 3, 2) & "/" & Left(d, 2) & "/" & Right(d, 2))
    Cells(1, 1) = d1

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!