Date Manipulation

jassi_123

Member
Hello Team,

I have a following value stored in a Test data item:-

Disabled (on Nov 07, 2018)

I would like to extract the date, month & Year from this text and wanted to calculate if the today's date has crossed the above date.

Can someone please tell me the best way to complete this task.

Regards,
(Jaspreet Singh)
 

sivagelli

Well-Known Member
Disabled (on Nov 07, 2018)

Is the text "Disabled (on" constant every time? If yes, you can use String function, Mid() to extract the date

Use a Calc Stage with the following expression:

DateDiff(9,Mid([TestDateItem],14,12),Today())

This returns difference of days between the passed date and Today(). A positive number indicates that the date in data item is past date.

Post back how it goes!
 

avadhesh.garg88

New Member
Hi @sivageli,
I have a text data item start_time which have value '1/2/2019 11:34 AM'.
I need to test if it is greater than Current date time - 2 hours.
can you please tell me the logic for this.

Thanks
 

sivagelli

Well-Known Member
Use the below expression in a Decision Stage, the 'yes' path would be considered if current data is greater than the 'start_time' else 'no' path would be considered indicating the current date time - 2 hrs is smaller than the date time in 'start_time'.

ToMinutes((Now()-MakeTimeSpan(0,2,0,0)) - ToDateTime([start_time])) > 0


Now() - This gives the current date time
MakeTimeSpan(0,2,0,0) - this indicates 2 hrs
Now()-MakeTimeSpan(0,2,0,0)) - subtracts 2hrs from current date time
ToDateTime([start_time]) - Converts text in start_time to date time
ToMinutes((Now()-MakeTimeSpan(0,2,0,0)) - ToDateTime([start_time])) - returns the minutes difference between the start_time and the current time in a number format. So when this is used in a decision stage along with arithmetic operators results in a either true or false.

Post back how it goes.
 
Top