CREATE OR REPLACE Function GetTianXiaoSFenZ(InYingWCSJ ZK_ShiXWDXX.YingWCSJ%Type, InWanCSJ BingRBL.WanCSJ%Type) Return VarChar2 is
Result VarChar2(40);
YingWCTime Date;
CurTime Date;
WanCSJ Date;
InDT Number;
Begin
YingWCTime := TO_DATE(SubStr(InYingWCSJ, 1, 10)||' '||SubStr(InYingWCSJ, 12, 8), 'yyyy-mm-dd hh24:mi:ss');
WanCSJ := TO_DATE(SubStr(InWanCSJ, 1, 10)||' '||SubStr(InWanCSJ, 12, 8), 'yyyy-mm-dd hh24:mi:ss');
InDT := WanCSJ - YingWCTime ;
If InDT >= 1 Then
Result := Trunc(InDT)|| '|'; -- 天
Else
Result := '0|';
End If;
--小时
If (InDT - Trunc(InDT)) * 24 >= 1 Then
Result := Result ||SubStr(To_Char( Trunc((InDT - Trunc(InDT)) * 24), '09'), 2, 2) ||'|'; -- 小时
End If;
--分
If ((InDT - Trunc(InDT)) * 24 - Trunc((InDT - Trunc(InDT)) * 24)) * 60 >= 1 Then
Result := Result || SubStr(To_Char(Trunc(((InDT - Trunc(InDT)) * 24 - Trunc((InDT - Trunc(InDT)) * 24)) * 60), '09'), 2, 2) ||'|'; --分钟
End If;
Return(Result);
End GetTianXiaoSFenZ;