var
date1,date2:tdatetime;
dt1,dt2,ds1,ds2:string;
procedure GlobalOnCreate;
begin
GetDateTimeRangeDialog(date1, date2);
dt1:= FormatDateTime('yyyy-mm-dd hh:nn:ss',date1);
dt2:= FormatDateTime('yyyy-mm-dd hh:nn:ss',date2);
ds1:= getsqlstringdata('select unix_timestamp("'+dt1+'")');
ds2:= getsqlstringdata('select unix_timestamp("'+dt2+'")');
ChangeReportSQL('select a.vstdate,a.vsttime,a.oqueue,a.hn,'+
'concat(pname,fname," ",lname) as ptname '+
',a.cur_dep,a.cur_dep_time,a.last_dep,a.main_dep,staff,c.name '+
'from ovst a '+
'left outer join patient b on a.hn=b.hn '+
'left outer join opduser c on a.staff=c.loginname '+
'where unix_timestamp(concat(a.vstdate," ",a.vsttime)) between "'+ds1+'" and "'+ds2+'" '+
'and a.staff in("yo","sod","ball","nek","auto","pooki","MART","nid","young","john") '+
'order by a.vn ');
end;