+ Reply to Thread
Results 1 to 20 of 20

How to subtract 1 hour from a 24hour time in string format value?

  1. #1
    Registered User
    Join Date
    10-04-2013
    Location
    Szentendre, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    78

    How to subtract 1 hour from a 24hour time in string format value?

    Hi guys,

    I have a lot of 24hour times - in string format - in column 'A', and I should subtract 1 hour. How should I do it?

    So, this is how it looks like: A column is the base, and B column is the desired ones. And column A is in string format.

    'A' 'B'
    12:40 11:40
    13:35 12:35
    15:20 14:20
    18:05 17:05

  2. #2
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: How to subtract 1 hour from a 24hour time in string format value?

    With Time Function

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    As Text Value

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Please do add reputation where you see fit, it's nice to be nice and we all enjoy a pat on the back

    Please also mark your thread as solved once it has been.

  3. #3
    Forum Expert cbatrody's Avatar
    Join Date
    04-15-2014
    Location
    Dubai
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    2,136

    Re: How to subtract 1 hour from a 24hour time in string format value?

    If the time in column A is in Text format, then try the following in B2:

    =TIME(LEFT(A2,SEARCH(":",A2)-1)-1,RIGHT(A2,2),0)

    OR,

    If column A is in Time format, try the following in B2:

    =TIME(HOUR(A2)-1,MINUTE(A2),0)

    OR

    =A2-1/24
    Last edited by cbatrody; 05-23-2017 at 07:45 AM. Reason: addition

  4. #4
    Registered User
    Join Date
    12-06-2016
    Location
    India
    MS-Off Ver
    2007
    Posts
    72

    Re: How to subtract 1 hour from a 24hour time in string format value?

    =text(b8,"hh:mm")-time(1,0,0)

  5. #5
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,984

    Re: How to subtract 1 hour from a 24hour time in string format value?

    b1
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  6. #6
    Registered User
    Join Date
    10-04-2013
    Location
    Szentendre, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: How to subtract 1 hour from a 24hour time in string format value?

    Quote Originally Posted by PFDave View Post
    With Time Function

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    As Text Value

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Thank you!

  7. #7
    Registered User
    Join Date
    10-04-2013
    Location
    Szentendre, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: How to subtract 1 hour from a 24hour time in string format value?

    Quote Originally Posted by cbatrody View Post
    If the time in column A is in Text format, then try the following in B2:

    =TIME(LEFT(A2,SEARCH(":",A2)-1)-1,RIGHT(A2,2),0)

    OR,

    If column A is in Time format, try the following in B2:

    =TIME(HOUR(A2)-1,MINUTE(A2),0)

    OR

    =A2-1/24
    Thank you, it is also working, thank you all, guys!

  8. #8
    Registered User
    Join Date
    10-04-2013
    Location
    Szentendre, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: How to subtract 1 hour from a 24hour time in string format value?

    Quote Originally Posted by shukla.ankur281190 View Post
    b1
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Thanks, it also working, but needs to convert the cell into time format. Cheers!

  9. #9
    Registered User
    Join Date
    10-04-2013
    Location
    Szentendre, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: How to subtract 1 hour from a 24hour time in string format value?

    Hi, PFDave,

    This is the formula, which I need, because it reamins the outcome in TEXT format as well, but it isn't working if the time is 20:00, because it thinks, it is 00:00.
    Where should I modify the formula?

    Quote Originally Posted by PFDave View Post
    As Text Value

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Thanks!

  10. #10
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: How to subtract 1 hour from a 24hour time in string format value?

    Ahh sorry -
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    10-04-2013
    Location
    Szentendre, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: How to subtract 1 hour from a 24hour time in string format value?

    Thanks, I'll look up it.
    I figured it out, but not with a nice solution: I copied another IF formula same as the 23 hour: if the hour is 20, then make it 19. But it is not so nice solution. Anyway, I'll try this now.

  12. #12
    Registered User
    Join Date
    10-04-2013
    Location
    Szentendre, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: How to subtract 1 hour from a 24hour time in string format value?

    Unfortunately, it's not okay.

    excel_subtract_hour.png

    This is my not so nice solution:
    Please Login or Register  to view this content.
    But to copy another IF formula into the IF formula is not a nice solution...

  13. #13
    Registered User
    Join Date
    10-04-2013
    Location
    Szentendre, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: How to subtract 1 hour from a 24hour time in string format value?

    Actually, I really don't understand, why it isn't working with the 20:00, and only with the 20:00.

  14. #14
    Forum Expert cbatrody's Avatar
    Join Date
    04-15-2014
    Location
    Dubai
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    2,136

    Re: How to subtract 1 hour from a 24hour time in string format value?

    Can you upload the example file in excel format instead of image please?

  15. #15
    Registered User
    Join Date
    10-04-2013
    Location
    Szentendre, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: How to subtract 1 hour from a 24hour time in string format value?

    Quote Originally Posted by cbatrody View Post
    Can you upload the example file in excel format instead of image please?
    Here it is:

  16. #16
    Forum Expert cbatrody's Avatar
    Join Date
    04-15-2014
    Location
    Dubai
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    2,136

    Re: How to subtract 1 hour from a 24hour time in string format value?

    Try the following in G1:

    =TIME(LEFT(E1,SEARCH(":",E1)-1)-1,RIGHT(E1,2),0)

    Please see the attached file.
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    10-04-2013
    Location
    Szentendre, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: How to subtract 1 hour from a 24hour time in string format value?

    Almost, but it's not working with eg. 00:30. But with the IF formula from the previous one, it will be good.
    As you see, I like to learn, can you tell me, why it didn't work between 20:00 an 20:59?

  18. #18
    Registered User
    Join Date
    10-04-2013
    Location
    Szentendre, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: How to subtract 1 hour from a 24hour time in string format value?

    Oh, no, it's not okay, because I need the result in text format as well.

    The reason I need it in text format as well (so, both the starting point is in string format, then I should subtract 1 hour, and then the result should be in string as well), because then I need the result, and "CONCATENATE" it with other strings as well..

  19. #19
    Forum Expert cbatrody's Avatar
    Join Date
    04-15-2014
    Location
    Dubai
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    2,136

    Re: How to subtract 1 hour from a 24hour time in string format value?

    Try the following in H1:

    =IF(LEFT(E1,2)="00","23"&RIGHT(E1,3),TEXT(LEFT(E1,2)-1,"00")&RIGHT(E1,3))
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    10-04-2013
    Location
    Szentendre, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: How to subtract 1 hour from a 24hour time in string format value?

    Yesss! )

+ 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] Subtract 1 hour from given date and time excluding off hours
    By melody10 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-14-2016, 03:07 PM
  2. Subtract 1 hour from given date and time excluding off hours
    By melody10 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-12-2016, 11:50 AM
  3. Convert 12hour time to 24hour time
    By hol4lar in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-29-2013, 03:34 PM
  4. [SOLVED] How to subtract time without entering colon and retain time format?
    By blmholland in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-08-2013, 10:36 PM
  5. subtract 2 24 hour times as string and return the number of minutes
    By jacol in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-22-2012, 01:00 AM
  6. Attempting to subtract time for a 24 hour period
    By JimM in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-19-2007, 09:51 AM
  7. [SOLVED] [SOLVED] How do i subtract a half hour from a time when >8 hrs.
    By lucy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-02-2006, 03:45 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