看似是时间加减运算,要求精确到1/1000秒(毫秒),结果用时间格式显示。
以下是引用mywisdom88在2022-7-8 10:19:33的发言:
楼主是想这样
HH:MM:SS.SSS的格式显示,加减也是按照HH:MM:SS.SSS的格式
你先这样,标准化你的参数,其他的,就容易了
HMSX = "1:2.1234"
*!* 取HHMMSS.SSS的.后面的前面3位
SSS = SUBSTR(IIF(RAT(".",HMSX)>0,SUBSTR(HMSX,RAT(".",HMSX)+1),"000"),1,3)
*!* 分别取HHMMSS中的SS,MM,HH
HMS = IIF(RAT(".",HMSX)=0,HMSX,SUBSTR(HMSX,1,RAT(".",HMSX)-1))
HMS = CHRTRAN(HMS,".","") && 防止HMS中还有"点"
SS = PADL(SUBSTR(IIF(RAT(":",HMS)>0,SUBSTR(HMS,RAT(":",HMS)+1),HMS),1,2),2,"0")
HM = IIF(RAT(":",HMS)=0,"00",SUBSTR(HMS,1,RAT(":",HMS)-1))
MM = PADL(SUBSTR(IIF(RAT(":",HM)>0,SUBSTR(HM,RAT(":",HM)+1),HM),1,2),2,"0")
HH = PADL(SUBSTR(IIF(RAT(":",HM)=0,"00",SUBSTR(HM,1,RAT(":",HM)-1)),1,2),2,"0")
?"前=",HMSX
?"后="+HH+";"+MM+";"+SS+"."+SSS
楼主是想这样
HH:MM:SS.SSS的格式显示,加减也是按照HH:MM:SS.SSS的格式
你先这样,标准化你的参数,其他的,就容易了
HMSX = "1:2.1234"
*!* 取HHMMSS.SSS的.后面的前面3位
SSS = SUBSTR(IIF(RAT(".",HMSX)>0,SUBSTR(HMSX,RAT(".",HMSX)+1),"000"),1,3)
*!* 分别取HHMMSS中的SS,MM,HH
HMS = IIF(RAT(".",HMSX)=0,HMSX,SUBSTR(HMSX,1,RAT(".",HMSX)-1))
HMS = CHRTRAN(HMS,".","") && 防止HMS中还有"点"
SS = PADL(SUBSTR(IIF(RAT(":",HMS)>0,SUBSTR(HMS,RAT(":",HMS)+1),HMS),1,2),2,"0")
HM = IIF(RAT(":",HMS)=0,"00",SUBSTR(HMS,1,RAT(":",HMS)-1))
MM = PADL(SUBSTR(IIF(RAT(":",HM)>0,SUBSTR(HM,RAT(":",HM)+1),HM),1,2),2,"0")
HH = PADL(SUBSTR(IIF(RAT(":",HM)=0,"00",SUBSTR(HM,1,RAT(":",HM)-1)),1,2),2,"0")
?"前=",HMSX
?"后="+HH+";"+MM+";"+SS+"."+SSS
是的是的,标准化字符串好重要,就怕用户乱输入,谢谢你提供代码