Question Steven Henry Suhendra · Jun 11, 2024

How To Calculate Date and Time in Different Column ?

Hy Friends,

I need some help, how to calculate date and time in different columns ?  

Does Anyone could help me ?

Thank you

Best Regards,

Steven Henry

Comments

Steven Henry Suhendra  Jun 11, 2024 to Oliver Thompson

Hy @Oliver Thompson 

Sure, I'm trying to calculate the difference between the 2 dates/times, but the problem is, it has a different columns (date and time), so does it mean that I've to combine it into 1 columns (Ex: DateTimeorder ->combine Date and Time Order, and DateTimeUpdate -> combine date update and time update) then calculate them or any other way to do it ?

Thank You

Steven Henry

0
Manel Trèmols  Jun 12, 2024 to Steven Henry Suhendra

Hi Steven,

You can user the CONCAT function

select OEORI_Date, OEORI_TimeOrd, OEORI_UpdateDate, OEORI_UpdateTime, DATEDIFF('n',{fn CONCAT({fn CONCAT(OEORI_Date,',')},OEORI_TimeOrd)},{fn CONCAT({fn CONCAT(OEORI_UpdateDate,',')},OEORI_UpdateTime)}) from SQLUser.OE_orditem
0
Oliver Thompson  Jun 13, 2024 to Steven Henry Suhendra

Thanks for the clarification.

The answers from @Manel Trèmols and @Ramil TK should both work for you.

You might have to do some additional formatting depending on what datePart you getting the difference in. For example if you get the difference in Minutes ("n"), then you will have to convert that into Days, Hours, Minutes etc, so it will depend on what you are expecting in the data and how big those differences might be.
 

0
Ramil TK · Jun 13, 2024

You can able to do like this also.

select OEORI_Date, OEORI_TimeOrd, OEORI_UpdateDate, OEORI_UpdateTime,

datediff('n',%EXTERNAL OEORI_Date||' '||%EXTERNAL OEORI_TimeOrd,%EXTERNAL OEORI_UpdateDate||' '||%EXTERNAL OEORI_UpdateTime)

from SQLUser.OE_orditem

0