+ Reply to Thread
Results 1 to 7 of 7

Change Date and Time stamp when time is less than 8 AM

  1. #1
    Forum Contributor
    Join Date
    12-22-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    205

    Change Date and Time stamp when time is less than 8 AM

    I have the following time and date stamp in a single cell

    9/20/2019 7:17:55 AM
    If the time portion is less than 8:00:00 AM, then i want an if statement that would take the existing date and time stamp and update the respective time portion to 8:00:00 AM

    Result would be
    9/20/2019 8:00:00 AM
    Any help would be greatly appreciated

    Thanks
    Last edited by jprlimey; 07-15-2020 at 12:09 PM. Reason: SOLVED

  2. #2
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: Change Date and Time stamp when time is less than 8 AM

    Try: =IF(A2-INT(A2)<0.333333,INT(A2)+TIME(8,0,0),A2)
    Click the * to say thanks.

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Change Date and Time stamp when time is less than 8 AM

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Forum Contributor
    Join Date
    12-22-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    205

    Re: Change Date and Time stamp when time is less than 8 AM

    I tried both solution and both worked. It's not clear cut if one work better than the other.

    To take one step further. As the 8am time could be different for some cases, i thought it best to put the 8am into a cell so the formula could reference it.

    Attachment 686528

    How best to reference the time from a cell into the formula

    Thanks

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Change Date and Time stamp when time is less than 8 AM

    Paul's and my solutions are basically the same, no advantage to using one over the other, depending on your preferences.
    To your question, with the critical timepoint in H1
    =IF(A2-INT(A2)<H1,INT(A2)+H1,A2)
    or
    =IF(MOD(A2,1)< H1, INT(A2)+H1, A2)

  6. #6
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    485

    Re: Change Date and Time stamp when time is less than 8 AM

    Another approach -- shorter formula with fewer reference calls:

    =INT(A2)+MAX(MOD(A2,1),H1)

  7. #7
    Forum Contributor
    Join Date
    12-22-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    205

    Re: Change Date and Time stamp when time is less than 8 AM

    Chemist B and PaulM100,

    Thanks so much for your assistance in solving this. Both solutions worked nice, i'll see over time which of the 2 i'll go with.

    Thanks again

+ 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] Calculation change date time stamp
    By mumzy in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 12-13-2016, 12:36 PM
  2. Need vba code to change date&time stamp as date format dd-mmm-yy in A:A rng
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-03-2014, 06:08 AM
  3. Date & Time stamp for change in value
    By drguruji in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2014, 04:09 AM
  4. Replies: 3
    Last Post: 11-06-2012, 01:37 AM
  5. How Change the Date \ Time Stamp of a file to a number ? (EXCEL VBA)
    By nawaralobaidi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-06-2012, 12:23 PM
  6. date time stamp - not to change
    By marsha7 in forum Excel General
    Replies: 5
    Last Post: 03-08-2012, 02:46 PM
  7. Excel Status Change w/ Time/Date Stamp
    By ritmoteca in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-14-2007, 10:43 AM

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