04-29-2016 04:10 PM - edited 03-15-2019 06:17 AM
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.
Solved! Go to Solution.
04-30-2016 04:31 AM
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
04-30-2016 04:31 AM
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
05-04-2016 11:59 AM
Thank you Chintan and Shalid. Good inputs, I will try these in my script and post final update
05-03-2016 08:45 AM
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,
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide