+ Reply to Thread
Results 1 to 30 of 30

Time Format Only

  1. #1
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Time Format Only

    Hello in my Time Sheet workbook there are cell values as:

    2/13/2018 1:28:01 PM in the formula bar

    Even though I set the format for Time (1:30 PM) as the choice in drop down.

    It appears as 1:28 PM

    I would prefer that in any occurrences of time they be 1:28 PM in the cell and in the formula bar.

    Is there any way to ensure this happens ? I am trying to understand why they are different.

    Thank you,
    Billy

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Time Format Only

    The formula bar shows the true value or a formula - somewhere we need to be able to see what is really going on.
    What you see in the cell is determined by formatting choice - this does not have to bear any resemblance to the underlying value - with display settings it can display as virtually anything.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Time Format Only

    Thank you for replying. I have times on the 'Switchboard', 'Log', and 'EMP' sheets.

    Is there a way to keep them consistent? There are codes to load the cells so maybe my issue is there.

    I have tried to reformat all of the cells so they are the same but no success yet.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Time Format Only

    I am away from my PC until tomorrow and so cannot download your file.
    (Unless it contains a formula) when you look in the formula bar it tells you what the underlying value is.
    it is possible that some of your values are text rather than numeric.
    If they are text rather than numeric, then you cannot make Excel display them the way you want - a date\time format only works if the underlying value is numeric.
    If the underlying value is text, then the text must be converted to the correct number before it can be formatted as a date or time
    You could investigate the cells that are not displaying the way you want.
    The formula...
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    ....returns TRUE if A1 contains a number and FALSE if it does not
    So, if you apply the formula against the cells that are misbehaving it may point you in the right direction
    If the formula returns FALSE you cannot format that value as a date or time

    Another way to achieve the same thing is to format a cell as a number to 2 decimal places - if you do not see a number displayed, then the underlying value is text.
    Last edited by kev_; 02-13-2018 at 06:41 PM.

  5. #5
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Time Format Only

    Kev,

    I think I see what is going on. The code puts the date and time in cells and I prefer it to show like : 8:05:05 AM

    Can this be done?

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Time Format Only

    the value time is just the time

    without understanding your code could you not get the time at the same time as clocktime, say put
    justtime=time

    as the line below in the vba code

    then write justtime to the cell rather than clocktime

  7. #7
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Time Format Only

    The code puts the date and time in cells and I prefer it to show like : 8:05:05 AM
    The number format to display like that is:"h:mm:ss AM/PM"
    Do you want the seconds displaying?

    I am a little unsure what you are asking for
    - the workbook you attached seems consistent
    - is it the VBA that is doing something you don't like?
    - I notice that the code is using function NOW which does include date and time
    - formulas require the date to handle anyone working past midnight etc

    this bit of code writes values to the sheet:
    Please Login or Register  to view this content.
    if you do not like what you are seeing
    Please Login or Register  to view this content.
    If you want anything else , please attach a workbook that ilustrates what you don't like - and make it obvious
    thanks

  8. #8
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Time Format Only

    Okay on the 'Switchboard' and 'Log' sheets the entries are filled by the codes.

    In cell E9 on 'Switchboard' for example in the formula bar for that cell it shows:

    2/13/2018 3:59:23 PM

    I would like it to show:

    3:59:23 PM

    When clicking on cell J13 in the formula bar it shows:

    1:30:00 PM (preferred)

    Also when the 'Log' sheet is filled by the code I want the preferred.

    Thank you so much for your help,
    Billy
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Time Format Only

    perhaps change the lines to
    Please Login or Register  to view this content.
    is that any closer?

  10. #10
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Time Format Only

    That did it thank you Mr. Davsth.

    The reason I wanted this changed is because I am manually entering times in the log for now to test out the calculations in the EMP sheets. I want to make sure they are accurate. When I manually enter it has a mix of code entries which had the date and time and the manual entries which only had the times. It was messing up the formulas.

    I figure it is better with your code now so all entries of time in the workbook will be without the date included.

    So much more consistent with your help thank you so much this has been frustrating but a valuable learning experience.

  11. #11
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Time Format Only

    just as long as shifts don't go over midnight!

  12. #12
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Time Format Only

    oh I didn't think of that but it probably will never happen.

    I noticed though that I had to remove the *1440 and /1440 from the formulas in the EMP sheets.

  13. #13
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Time Format Only

    I think I messed up again sorry can you check my formulas? On the EMP101 it isn't adding up the hours.
    Attached Files Attached Files

  14. #14
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Time Format Only

    I have it figured out thanks again for your help.

  15. #15
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Time Format Only

    glad to hear, I am not party to your logic in the time calculations, although they could be simplified!

    what if the following was uses in i13 =IF(COUNTIF(E13:H13,""),"",MIN(F13,$H$5)-MAX(D13:E13)+MIN(H13)-MAX(G13,H6))

    a few less ifs!

  16. #16
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Time Format Only

    I am confusing myself and agree with your logic instead. Could you try it out and post revision? The flex times use different criteria because they don't rely on shift schedules.

    I really appreciate it!

  17. #17
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Time Format Only

    It does work however if an employee clocks in before lunch out time he should get paid until Lunch end from H6

  18. #18
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Time Format Only

    I found it :

    =IF(COUNTIF(E11:H11,""),"",MIN(F11,$H$5)-MAX(D11:E11)+MIN(H11)-MAX(G11,$H$6))

  19. #19
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Time Format Only

    Well done! it was only a thought to make it slightly less messy. It made sense in my head, I did not want to confuse you!

  20. #20
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Time Format Only

    How about the flex times have you come up with a formula? I will try

  21. #21
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Time Format Only

    How about this does it work?

    =IF(COUNTIF(E16:H16,""),"",(F16-E16)+(H16-G16))

  22. #22
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Time Format Only

    it depends if a person can work a half day flexi and so not taKe lunch


    if they can't it works

    otherwise maybe something like
    =IF(COUNTIF(E16:F16,""),0,F16-E16)+IF(COUNTIF(G16:H16,""),0,H16-G16)

  23. #23
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Time Format Only

    Yours is obviously better thanks again! I hope I can return the favor(s) one day.

  24. #24
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Time Format Only

    oh darn it. I have a crazy one here Suppose an employee is feeling sickly and doesn't follow their schedule but does do some work before going home early?

    I attached and example in EMP102
    Attached Files Attached Files

  25. #25
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Time Format Only

    Im not sure how the sheet is populated I assume they just press and get silly values in the afternoon

    =IF(COUNTIF(E13:F13,""),"",MIN(F13,$H$5)-MAX(D13:E13))+IF(OR(COUNTIF(G13:H13,""),G13<0.5),0,MIN(H13)-MAX(G13,$H$6)) perhaps

  26. #26
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Time Format Only

    It is populated by their clocking in or out on the 'Switchboard' sheet. It also populates the 'Log' sheet.

    For now I am manually entering times in the 'Log' sheet for different scenarios.

  27. #27
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Time Format Only

    That is very close but what if they don't work one day? I am getting #VALUE!

  28. #28
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Time Format Only

    =IF(COUNTIF(E13:F13,""),0,MIN(F13,$H$5)-MAX(D13:E13))+IF(OR(COUNTIF(G13:H13,""),G13<0.5),0,MIN(H13)-MAX(G13,$H$6)) perhaps

  29. #29
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Time Format Only

    Thank you I have been such a bother but do appreciate the help.

    I will run this through the paces over a few days and try to come up with many scenarios to see if it breaks.

    Enjoy the rest of your day sir

  30. #30
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Time Format Only

    my day is nearly done, I'm off home in a few minutes. you have a good day. the formulas can be changed, but if you can express what you want in english, the formulas can be built or modified, enjoy your day

+ 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. VBA calculate sleep time, when time is entered in military time format
    By axm1955 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-29-2017, 10:28 AM
  2. [SOLVED] time sheet help, format TIME and formula based on the actual time entered.
    By bh mng in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 12-06-2016, 01:10 PM
  3. Format time from military time to standard time
    By Valencia0307 in forum Excel General
    Replies: 7
    Last Post: 06-01-2014, 11:15 AM
  4. Change format of lots of data cell to a time format
    By dazza67 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-24-2013, 03:24 PM
  5. Convert date and time in serial number format to text format
    By nda13112 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-11-2013, 02:45 PM
  6. Excel: How to convert time format into number format that can be added?
    By Frances Jones in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-17-2012, 04:10 PM
  7. Display time in time format instead of decimal format
    By CasualVisitor in forum Excel General
    Replies: 5
    Last Post: 07-03-2009, 06:24 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