You may wish to also include
&& (@dischargeDate ne @null)
also .. thought of this ..
as long as the date/time strings are of the same length, you should be able to perform lt and gt on them .. but they must be of the same length ..
200510020830
will be less than (in strings)
200511090005
will be less than (in strings)
200511090010
as long as your dates/times are HL7 format .. then .. you should be ok for gt and lt comparison (and they are of the same length) ..
guess someone should fully test .. but I don’t see a hole at this time..
Dennis