A:
功能实现:返回指定日已完成的最近季度的最后一个交易日。
即,假设今日为20240718T,则最近的已完成的最近季度为20240630
若假设今日为20240628T,则最近的已完成的最近季度还是为20240630,因为2024年6月29与30日为非交易日,本季度后续没有其它交易日。
若假设今日为20240627T,则最近的已完成的最近季度为上季度,即20240331。
endt:=20240718T;//today();
dEndt:=datetoint(endt);
bT:=StartOfTheQuarter(endt);
eT:=EndOfTheQuarter(endt);
t:= sselect ['截止日'] from infotable 753 of 'SH000001'
where ['是否交易日']=1 and ['截止日']<=datetoint(eT) and ['截止日']>=datetoint(bT-20)
order by ["截止日"] desc end;
if istable(t) then
begin
if t[0]>dEndt then
t:=sselect thisrow from t where thisrow<datetoint(bT) end;
return t[0];
end
else return 0;
返回整数:20240628
若需要转成日期,则可使用inttodate(endt)进行转换。