Date difference In Collection

Patnaik14

Member
Hi All,

I am getting the output as the date (In this format 16-12-2018 18:30:00) in two collection field.
How to find the difference.
The requirement is to get only the day count (Like 2 or 3 or 4 Days)

Please advise.
 

sivagelli

Well-Known Member
Use a calc stage with expression: ToDays([Col1.Field1] - [Col1.Field2]) to get the difference in days. This works considering Field1 and Field2 are of type 'DateTime', if they are of 'Text' type then use expression: ToDays(ToDateTime([Col1.Field1]) - ToDateTime([Col1.Field2]))
 

nilsbabar

New Member
Use a calc stage with expression: ToDays([Col1.Field1] - [Col1.Field2]) to get the difference in days. This works considering Field1 and Field2 are of type 'DateTime', if they are of 'Text' type then use expression: ToDays(ToDateTime([Col1.Field1]) - ToDateTime([Col1.Field2]))



This will throw an error if date format is changed.
like Text1= 23.02.2019
Text2 = 02.02.2019

If system's date format is " mm.dd.yyyy " then Robot will fail to genarate result.


to get exact difference between data you can check following code:

DateDiff(9, MakeDate(Left([Order Received ], 2), Mid([Order Received ], 4, 2), Right([Order Received ], 4)), MakeDate(Left([Delivery Date], 2), Mid([Delivery Date], 4, 2), Right([Delivery Date], 4)))
 
Top