Comparing Dates
Hi,
Any suggestion on how to compare dates? Below is my code but it does not seem to work.
USER>w $zdate(zdateh(x,8),1) > $zdate($zdateh(y,8),1)
When I set x to "06/01/2022" and set y to "04/01/2022" gives me an output of 1
When I set x to "09/01/2019" and set y to "04/1/2022" still gives me an output of 1
Any help is appreciated.
Thanks!
Comments
Hi.
Just compare
w zdateh(x,8) > $zdateh(y,8)
Regards,
Matjaž
It worked! Thank you so much.
What happens if you try this?
w $zdateh(x,1) > $zdateh(y,1)
This worked as well! Thank you for your input!
Which format do you use - DD/MM/YYYY?
Be carefull : the second parameter of $zdateh is =1 for US format (mm/dd/yyyy), =4 for European format (dd/mm/yyyy) and =8 for yyyymmdd format.
Luckily, $zdateh is smart enough to know your date is really US and not yyymmdd, but the correct answer is to use $zdateh(x,1) > $zdateh(y,1), and not 8 as second parameter :
write $zdateh("05/01/2022",1)
66230 -> the internal date for may 1st 2022
write $zdateh("05/01/2022",4)
66114 -> the internal date for 5 january 2022
write $zdateh("05/01/2022",8)
66230 -> $zdateh expects yyyymmdd, assumes this is US format (but this is wrong if European format was intended)Gotcha! that's really helpful. Appreciate the input. Thank you!