+ Reply to Thread
Results 1 to 4 of 4

Converting time format

  1. #1
    Forum Contributor
    Join Date
    03-14-2005
    Location
    Sweden
    MS-Off Ver
    Office 365
    Posts
    329

    Converting time format

    Hello.

    I have a range containing dates in this format:
    YYYYWWD
    2010021 or
    Year 2010 week 2 day 1

    I would like to convert this to new date format 2010-01-11 (11th of january).

    How can this be done? Any ideas?

    /Anders

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Converting time format

    If we assume that Week 1 commences from first Mon of year then perhaps:

    =DATE(IF(ISNUMBER($A1);LEFT($A1;4);MID($A1;6;4));1;1)-(WEEKDAY(IF(ISNUMBER($A1);LEFT(A1;4);MID(A1;6;4))&"-01-01";3)-7)+7*(MID($A1;IF(ISNUMBER($A1);5;16);2)-1)+RIGHT($A1)-1

    where A1 holds either the number or text string

  3. #3
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Converting time format

    Hi,

    Among many possibilities ...
    see attached file

    HTH
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    08-07-2013
    Location
    Mordor
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Converting time format

    Even if this is an old thread I post my solution.
    I adapted other solutions to suit my needs, perhaps it will be of use for somebody else.

    With ; as separator in the formula:
    =DATE(LEFT(A1;4);1;0)+((MID(A1;5;2)-1)*7)+RIGHT(A1;1)-VLOOKUP(LEFT(A1;4)+0;Sheet2!$A$1:$B$10;2;FALSE)
    With , as separator:
    =DATE(LEFT(A1;4);1;0)+((MID(A1;5;2)-1)*7)+RIGHT(A1,1)-VLOOKUP(LEFT(A1,4)+0,Sheet2!$A$1:$B$10,2,FALSE)

    The formula makes a date of the YYYY (ie 2010-01-00 = 2009-12-31) and then adds WW-1*7 and adds D. Finally it looks up and subtract the number of days in W1 belonging to previous year listed in sheet2 as follow (a negative number is no days in current year belonging to w52 last year). The +0 is to make sure that the year is in number format and not text.
    SHEET2:
    2005 -2
    2006 -1
    2007 0
    2008 1
    2009 3
    2010 -3
    2011 -2
    2012 -1
    2013 1
    2014 2
    2015 3

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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