if formula with date/time field

RattlingCarp3048

Board Regular
Joined
Jan 12, 2022
Messages
202
Office Version
  1. 365
Platform
  1. Windows
There is probably an easy solution i am overlooking but if someone could get me in the right direction that would be great.

I have a data set that is extracted from a program. The date and time is in one field formatted to military time. I am trying to write a formula that states if the time is <= 1300, then put original date+1, if not put the original date. Excel no matter what combination or format i write the formula it sill +1 to everything regardless of the time.

current formula =IF(I2<="3 PM",I2+1,I2)
previously tired =IF(I2<="1300",I2+1,I2)

Original: 4/4/23 16:16​
what it should be: 4/5/2023​
what formula returned: 4/5/2023​
this was after 3pm on 4/4 so formula should return next day's date of 4/5
4/5/23 5:56​
4/5/2023​
4/6/2023​
this is before 3pm on 4/5 so formula should return original date of 4/5
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi,

For your military time to be converted to standard Excel time, you can use following formula
Excel Formula:
=TIMEVALUE(LEFT(A1,2)&”:”&RIGHT(A1,2)).

Once you have this result, you can perform the calculations you require ...
 
Upvote 0
will this work?:
mr excel questions 22.xlsm
AB
4timecalculation
52023-04-04 20:162023-04-05 00:00
62023-04-04 08:162023-04-04 00:00
RattlingCarp3048
Cell Formulas
RangeFormula
B5:B6B5=INT(A5)+IF(MOD(A5,1)>=TIME(13,0,0),1,0)
 
Upvote 0
Solution
Hi,

For your military time to be converted to standard Excel time, you can use following formula
Excel Formula:
=TIMEVALUE(LEFT(A1,2)&”:”&RIGHT(A1,2)).

Once you have this result, you can perform the calculations you require ...
this didnt work. i got a #NAME error.
 
Upvote 0
@RattlingCarp3048 , I think you have your signs in the wrong order. In your paragraph you use < 1300 to add one to the day. But, in your table of expectations you seem to be wanting to add if the hour is beyond 1300.

Please look at the solution offered in post #3.
 
Upvote 0
Do you want before 1300 or before 3PM, they are not the same
 
Upvote 0
will this work?:
mr excel questions 22.xlsm
AB
4timecalculation
52023-04-04 20:162023-04-05 00:00
62023-04-04 08:162023-04-04 00:00
RattlingCarp3048
Cell Formulas
RangeFormula
B5:B6B5=INT(A5)+IF(MOD(A5,1)>=TIME(13,0,0),1,0)
this didnt work either. still giving all line items +1 to the date regardless of the time

3/7/23 1:04 PM​
3/7/2023​
3/8/2023​
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,198
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top