Question
· Jun 13, 2022

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!

Product version: IRIS 2020.2
$ZV: HealthShare 2020.2 [HealthShare Modules: Core:20.1.8624 + Patient Index:20.0.8624] - IRIS for UNIX (IBM AIX for System Power System-64) 2020.1 (Build 217_1_20418U) Mon Dec 21 2020 12:09:33 EST
Discussion (7)0
Log in or sign up to continue

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)