Add a variable hour/minute to a Datetime field

Hi guys,
if we do [Datetime field] + โ€œ002:00:00โ€, it results in 2 hours after that datetime. Great !
But I need to add a variable number of hours. I tried to use CONCATENATE to mount a string in place of โ€œ002:00:00โ€ but it didnโ€™t work.

It worked when I used DATETIME function to brake down all parts and rejoin it, like this: DATETIME(CONCATENATE(TEXT(DATE([Start]),โ€œMM/DD/YYYYโ€)," ",TEXT(TIME([Start])+[Hours],โ€œHH:MM:SSโ€)))

But I guess there should be a more simple and direct wayโ€ฆ

Thanks for any help !

0 3 738
3 REPLIES 3

Date / Time / Duration computations are typically complex and lengthy.

Your postโ€™s title says โ€œAdd a variable hour/ minuteโ€ but your shared expression only adds [Hours] .
Could you clarify?

Assuming you only wish to add [Hours], the expression you have shared will not roll over the date into the next date. For example, if 21 hours are added to a date time of โ€œ17/11/2021, 08:41:16 amโ€ , it should actually calculate the result to โ€œ18/11/2021, 05:41:16 amโ€ but the expression you shared will calculate it as โ€œ17/11/2021, 05:41:16 amโ€ that is, it will compute without date change.

If you wish to incorporate date change as well when it is expected to, please try the following expression
[Start]+ (TIME([Hours]&":00:00")-โ€œ00:00:00โ€)

Hi @Suvrutt_Gurjar , in fact, I mentioned hour/minute, but I really need add only hours in this moment. Thanks for your alert about rolling over into the next date and, of course, for your more clean solution. Best !

Steve
Platinum 4
Platinum 4

For reference:

Top Labels in this Space