How To Calculate Date and Time in Different Column ?
Hy Friends,
I need some help, how to calculate date and time in different columns ? .png)
Does Anyone could help me ?
Thank you
Best Regards,
Steven Henry
Comments
Can you clarify what you are trying to do please?
Are you trying to calculate the difference between the 2 dates/times? If that is the case have a look at the DATEDIFF(..) SQL functions.
https://docs.intersystems.com/iris20241/csp/docbook/Doc.View.cls?KEY=RS…
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
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_orditemDear @Manel Trèmols
Thank you, it works for me
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.
Dear @Oliver Thompson
it works, thank you
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
Dear @Ramil TK
it works, thank you