+ Reply to Thread
Results 1 to 13 of 13

Needing Foratting formula to set time to 24 hours

  1. #1
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Needing Foratting formula to set time to 24 hours

    Hello All,

    Needing to update this code so that the formula format produces 24 hr time

    This is the information that this string produces = 44542 (This is in the cell) when I need it to produce = 14:15:00

    Please Login or Register  to view this content.
    Any thoughts would be helpful

    Regards,

    John
    Last edited by JJFletcher; 01-03-2022 at 07:24 AM.

  2. #2
    Valued Forum Contributor janmorris's Avatar
    Join Date
    07-24-2021
    Location
    Japan
    MS-Off Ver
    Google Sheets (& Mac 2021)
    Posts
    1,090

    Re: Needing Foratting formula to set time to 24 hours

    are you looking for a standard excel formula, or a formula to be used in VBA or something else?

    the reason i ask is that the code you have provided is not a standard excel formula, and therefore the enquiry doesnt make sense in its current format.

  3. #3
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Needing Foratting formula to set time to 24 hours

    Hi Janmorris,

    So this would fall under a Macro?

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,872

    Re: Needing Foratting formula to set time to 24 hours

    The formula appears to be rounding a date+time stamp to the nearest 15 minutes. A result of 44542 is the date/time serial number for midnight on the morning of 21 Dec. 2021.

    If your intention is to simply use Excel's date/time serial number system, then it sounds like you need to add a suitable number format for this cell (Range.NumberFormat property: https://docs.microsoft.com/en-us/off...e.NumberFormat See this help page for valid number format codes: https://support.microsoft.com/en-us/...7-9c9354dd99f5 ).

    A number format of "yyyy/mm/dd hh:mm:ss" will display a date/time serial number with the full date time information (24 hour clock). The number 44542 will display as 2021/12/21 0:00:00.

    Is that what you are trying to do, or am I misunderstanding something?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Needing Foratting formula to set time to 24 hours

    Mr Shorty,

    You are accurate... I am attempting to once the formula pulls the information from the cell in Column A is then to convert that to a time stamp to the nearest 15 minutes.
    Last edited by JJFletcher; 01-03-2022 at 05:53 AM.

  6. #6
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Needing Foratting formula to set time to 24 hours

    I need to format to 24 hour clock ... The user can select to format and select time and then 13:30:55, but I want VBA to do the conversion.

    I have tried

    Please Login or Register  to view this content.
    But I am getting #VALUE! error

    Any thoughts would be appreciated!

    Regards,

    John
    Last edited by JJFletcher; 01-03-2022 at 06:19 AM. Reason: update data

  7. #7
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Needing Foratting formula to set time to 24 hours

    UPDATE:

    I have changed the code to reflect this and the #VALUE! changes and provides the time - yet I need the time to show in 15 minutes intervals

    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Needing Foratting formula to set time to 24 hours

    Perhaps next formula
    =TEXT(INT(A1*24*60/15)*15/60/24;"hh:mm:ss")
    - Battle without fear gives no glory - Just try

  9. #9
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Needing Foratting formula to set time to 24 hours

    Hi PCI,

    I really appreciate your feedback Thanks!!!

    When attempting this solution I receive a Syntax Error - Compile Error


    I tried by adding "" to the formula and it changes the error from Syntax Error - Compile Error to Application-Defined or Object-defined error

    changed to

    Please Login or Register  to view this content.
    Last edited by JJFletcher; 01-03-2022 at 07:07 AM.

  10. #10
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Needing Foratting formula to set time to 24 hours

    See next statement

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Needing Foratting formula to set time to 24 hours

    PCI,

    That did the job - It works - Thank you so much

    Have a great New Year

  12. #12
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Needing Foratting formula to set time to 24 hours

    Good news.
    Have a great new year to , with Excel of course and thank you for the rep.

  13. #13
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,872

    Re: Needing Foratting formula to set time to 24 hours

    You've marked this as solved, so there may be nothing more to really add. However, I would point out that the solution you've settled on (using the TEXT() function) stores a time (a number) as text. We have frequent threads on this forum about problems with numbers stored as text. It is up to you as the programmer to make this decision. Before settling on this solution, I would suggest that you consider what problem you are solving by storing the time/number as text and contrast that against other potential problems that you are creating by storing the time/number as text. Make sure that you like having a time/number stored as text.

+ 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. Time vs. hours - too many hours and formula won't work
    By Terri Earley in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-19-2021, 01:54 PM
  2. [SOLVED] Timesheet that calcs time in, time out, lunch used, reg hours, ot hours, double hours
    By noobface in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-21-2021, 03:45 AM
  3. Formula for Timesheet - Double Time, Time Half and normal Hours
    By Tracs13 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 09-12-2017, 09:40 PM
  4. [SOLVED] Formula to fill C5 with a time that makes J5 equal 8 hours based on time put into B5
    By possumbarnes in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-26-2015, 10:08 PM
  5. [SOLVED] Formula to Calculate Normal Hours, Time & 1/2 & Double Time from Daily Hours per week
    By KazzICC in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-17-2014, 01:51 AM
  6. [SOLVED] Needing to combine 2 IF statements in one Cell. Time Schedule minus lunch time
    By cody_o in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-26-2013, 04:10 PM
  7. Replies: 1
    Last Post: 03-27-2006, 01:10 PM

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