cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2391
Views
5
Helpful
3
Replies

How to compare datetime in ICM script with current datetime

Ravindra Adhav
Level 1
Level 1

Hi,

I am sending datetime in following format to ICM routing script as call variable. 

Call Variable 1: 2016-04-29 22:30:00

I want compare this date in IF with current system datetime in ICM routing script and based on result decide further routing of task. I tried built functions like date() but that doesn't help. Can anyone help me here what function or custom code I should use to compare date which is sent in above format with current date time. 

1 Accepted Solution

Accepted Solutions

Chintan Gajjar
Level 8
Level 8

date() function in ICM only takes specific type of input, so i would do it like this.

i would first separate the date and time which CPV holds in 4 diff chunks.

YYYY =  substr(CPV1,1,4)

MM=substr(CPV1,6,2)

DD=substr(CPV1,8,2)

Time = substr(CPV1,12,8)

now to compare simply you can build up logic.

if date(YYYY,MM,DD) >=< date() (date() will give current date of the system)

so eventually formula would look like:

date(substr(CPV1,1,4),substr(CPV1,6,2),substr(CPV1,8,2)) > date()

and now for time we will do it in same way, the base formula is time(HH:MM:SS) >=< time()

so eventually the formula would look like,

time(substr(CPV1,12,8)) >=< time()

while doing above please make sure you evaluate the substr() function giving correct string outputs.

 

and also there might be easy way to do it, but i am only aware of above :).

Hope it helps

Regards

Chintan

View solution in original post

3 Replies 3

Chintan Gajjar
Level 8
Level 8

date() function in ICM only takes specific type of input, so i would do it like this.

i would first separate the date and time which CPV holds in 4 diff chunks.

YYYY =  substr(CPV1,1,4)

MM=substr(CPV1,6,2)

DD=substr(CPV1,8,2)

Time = substr(CPV1,12,8)

now to compare simply you can build up logic.

if date(YYYY,MM,DD) >=< date() (date() will give current date of the system)

so eventually formula would look like:

date(substr(CPV1,1,4),substr(CPV1,6,2),substr(CPV1,8,2)) > date()

and now for time we will do it in same way, the base formula is time(HH:MM:SS) >=< time()

so eventually the formula would look like,

time(substr(CPV1,12,8)) >=< time()

while doing above please make sure you evaluate the substr() function giving correct string outputs.

 

and also there might be easy way to do it, but i am only aware of above :).

Hope it helps

Regards

Chintan

Thank you Chintan and Shalid. Good inputs, I will try these in my script and post final update 

simple way to check the current time in ICM script is to use the built in function now(). Built in function now () returns the date and time during the script execution. 

Example:

now()>=date(2014,09,25)+time(14,00) 

I havent tried with PV , but it worth trying once. 

Regards,