+ Reply to Thread
Results 1 to 2 of 2

Convert string dates and times to different format

Hybrid View

  1. #1
    Registered User
    Join Date
    07-31-2014
    Location
    texas
    MS-Off Ver
    2010
    Posts
    22

    Convert string dates and times to different format

    Basically I want to take this type of date:

    November 22, 2001, 9:23:30 p.m. EST

    and automatically convert it to

    2001_326:09:23:30.000

    Where 326 represents what day out of 365 Nov 22 is.

    Is this possible?

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Convert string dates and times to different format

    I think that this should be relatively simple.

    On second thoughts I decided to use a user defined function as this allowed my to use two arrays to simplify the process.

    Function MyDate(MyStr As String)
    
    MyArray = Split(MyStr, " ", -1, 1)
    
    If MyArray(4) = "p.m." Then
    
    temp = Split(MyArray(3), ":")
    
    MyArray(4) = temp(0) + 12 & ":" & temp(1) & ":" & temp(2)
    
    End If
    
        MyDate = Left(MyArray(2), 4) & "_" & DateDiff("d", "01-01-" & Left(MyArray(2), 4), Left(MyArray(1), 2) & "/" & MyArray(0) & "/" & Left(MyArray(2), 4)) + 1 & ":" & MyArray(4) & ".000"
    
    End Function
    Attached Files Attached Files
    Last edited by mehmetcik; 10-22-2014 at 03:27 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 08-11-2014, 07:08 PM
  2. String of dates convert to a from and to date
    By Mikey G in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-12-2014, 12:14 PM
  3. Convert Dates in 2011:08:17 format into Dates in Excel
    By JessRI in forum Excel - New Users/Basics
    Replies: 12
    Last Post: 09-11-2012, 09:55 AM
  4. Convert string dates to proper numerical date format
    By Codpops in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-21-2008, 01:01 PM
  5. Excel date format convert to string format
    By man in forum Excel General
    Replies: 1
    Last Post: 08-17-2006, 05:05 AM

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