+ Reply to Thread
Results 1 to 4 of 4

Excel 2007 : Converting to date and time formats

  1. #1
    Registered User
    Join Date
    06-28-2011
    Location
    wales
    MS-Off Ver
    Excel 2007
    Posts
    9

    Unhappy Converting to date and time formats

    I have exported some data from Crystal Reports which includes date and time fields. Unfortunately the data shows as two seperate fields YYYY-MM-DD and the time as HHMM.
    So, I have a start date/time like
    (cell A1) 2011-04-15 (cell A2) 1245
    and an end date and time like
    (cell A3) 2011-04-16 (cell A4) 0700
    I want to calculate the time difference between these two dates/times and presumably need firstly to combine the start and end date /time entries respectively but of course excel isn't recognising these fields as genuine date and time fields and so any concatination doesn't give a true date/time field.
    Two question therefore.
    1 - How do I convert these fields so they are genuine date and time fields and that they can then be combined.
    2 - How do I calculate the time difference in hr and mins

    Many thanks in advance of a solution.
    Last edited by ronbailey; 06-28-2011 at 07:52 AM.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Converting to date and time formats

    Try:

    =(DATEVALUE(A3)+TIMEVALUE(LEFT(B3,2)&":"&RIGHT(B3,2)))-(DATEVALUE(A1)+TIMEVALUE(LEFT(B1,2)&":"&RIGHT(B1,2)))

    Custom formatted as [h]:mm

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    06-28-2011
    Location
    wales
    MS-Off Ver
    Excel 2007
    Posts
    9

    Thumbs up Re: Converting to date and time formats

    Quote Originally Posted by Domski View Post
    Try:

    =(DATEVALUE(A3)+TIMEVALUE(LEFT(B3,2)&":"&RIGHT(B3,2)))-(DATEVALUE(A1)+TIMEVALUE(LEFT(B1,2)&":"&RIGHT(B1,2)))

    Custom formatted as [h]:mm

    Dom
    Excellent - Wasn't sure why I was getting a 'Circular Ref' warning initially but then realised that my data was all in column A and you had reference to data in column B. I changes my data to A1, A3, B1, B3 and it all worked well. Many thanks for this - appreciate it

    Ron

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

    Re: Converting to date and time formats

    FWIW, you might find you could use

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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