+ Reply to Thread
Results 1 to 2 of 2

How to join datevalue and timevalue into one

  1. #1
    Registered User
    Join Date
    06-11-2011
    Location
    south africa
    MS-Off Ver
    Excel 2007
    Posts
    26

    How to join datevalue and timevalue into one

    Good day All,

    I have a spreadsheet with 6 spin buttons - one for year - two for month - three for day - four for hour - five for minute - six for second
    I have two sets of these, the first set returns the start date and the second set returns the end date - if you type the date and time in a cell and do the same in another then you'll get the correct answer, so many years, months and etc. However in one cell I have a formula =DATEVALUE(G30 & "/" & J30 & "/" & D30) and in another cell have a formula =TIMEVALUE(M30& ":" & P30 & ":" & S30) now the formula I have used to combine the two CONCATENATE this is the formula -

    =CONCATENATE(YEAR((D23))-YEAR(D2)-IF(OR(MONTH((D23))<MONTH(D2),AND(MONTH((D23))=MONTH(D2),DAY((D23))<DAY(D2))),1,0)&" YEAR(S), "&MONTH((D23))-MONTH(D2)+IF(AND(MONTH((D23))<=MONTH(D2),DAY((D23))<DAY(D2)),11,IF(AND(MONTH((D23))<MONTH(D2),DAY((D23))>=DAY(D2)),12,IF(AND(MONTH((D23))>MONTH(D2),DAY((D23))<DAY(D2)),-1)))&" MONTH(S), "&(D23)-DATE(YEAR((D23)),MONTH((D23))-IF(DAY((D23))<DAY(D2),1,0),DAY(D2))&" DAY(S), ",IF(HOUR(N23)-HOUR(N2)<0,HOUR(N23)-HOUR(N2)+24,HOUR(N23)-HOUR(N2))," HOUR(S), ",IF(MINUTE(N23)-MINUTE(N2)<0,MINUTE(N23)-MINUTE(N2)+60,MINUTE(N23)-MINUTE(N2)), " MINUTE(S), ",IF(SECOND(N23)-SECOND(N2)<0,SECOND(N23)-SECOND(N2)+60,SECOND(N23)-SECOND(N2)), " SECOND(S) ")

    the answer is not correct, somehow it can't or doesn't work between the day and hour.

    For example wed 22 feb 2012 20:36:00 and the other date is sat 22 feb 2014 20:35:00
    the correct answer would be 1 years, 11 months, 30 days, 23 hours, 59 minutes, and 00 seconds
    BUT using the datevalue and timevalue as explained the answer is not correct 2 years, 0 months, 0 days, 23 hours, 59 minutes, and 00 seconds

    I have tried other formula's too, eg: =DATEDIF(A1,A2 -(MOD(A1,1)>MOD(A2,1)),"y")&" years, "&DATEDIF(A1,A2 -(MOD(A1,1)>MOD(A2,1)),"ym")&" months, "&DATEDIF(A1,A2 -(MOD(A1,1)>MOD(A2,1)),"md")&" days, "&TEXT(MOD(A2-A1,1),"hh "" hours, "" mm "" minutes, and "" ss ""seconds""") which this formula users date and time in one cell, the next formula users the date from one cell adn the time from another

    =DATEDIF(A7,A15 -(MOD(A7,1)>MOD(A15,1)),"y")&" years, "&DATEDIF(A7,A15 -(MOD(A7,1)>MOD(A15,1)),"ym")&" months, "&DATEDIF(A7,A15 -(MOD(A7,1)>MOD(A15,1)),"md")&" days, "&TEXT(MOD(B15-B7,1),"hh "" hours, "" mm "" minutes, and "" ss ""seconds""")

    I know there is a simple answer, but I just somehow either don't see it or I don't know

    Many thanks

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: How to join datevalue and timevalue into one

    Hi, Quintin,

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    http://www.mrexcel.com/forum/excel-q...-into-one.html

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ 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. [SOLVED] SQL Join - Left Join, but with 4 tables
    By kenny.fsw in forum Access Tables & Databases
    Replies: 4
    Last Post: 05-29-2013, 09:03 AM
  2. Timevalue
    By merl4 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-02-2013, 08:40 AM
  3. timevalue
    By tomfromportage in forum Excel General
    Replies: 2
    Last Post: 03-24-2012, 05:20 PM
  4. Ontime Now + TimeValue
    By trinn89 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-23-2011, 07:53 PM
  5. [SOLVED] iserror(Timevalue())
    By Basil in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-05-2005, 09:06 AM

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