Basic Date Meta-SQL Guidelines
You can avoid confusion when using meta-SQL such as %Datein and %Dateout if you remember to use "in" functions in the Where subclause of a SQL query and to use "out" functions in the Select (main) clause of the query. For example:
select emplid, %dateout(effdt) from ps_car_alloc a where car_id = '" |⇒
®ISTRATION_NO | "' and plan_type = '" | &PLAN_TYPE | "' and a.effdt = ⇒
(select max (b.effdt) from ps_car_alloc b where a.emplid=b.emplid and b.effdt <=⇒
%currentdatein) and start_dt <= %currentdatein and (end_dt is null or end_dt >=⇒
%currentdatein)";