您的位置:首页 > 编程语言 > Qt开发

QTP的那些事---时间格式转换函数

2011-12-31 17:15 127 查看
*******************************************************************************************
'功能:时间字符串格式转换
'参数:str代表时间字符串,formatdata代表需要截取的字符
'返回值:获取你所需指定的单元格的值
'作者:
'*******************************************************************************************
FunctiondateFormat(str,formatdata)
t=Split(str,formatdata,-1,1)
newstr=join(t,"")
dateFormat=newstr
Endfunction
'时间格式转换
FunctionFormateDateTime(sendTime,Para)
selectcasePara
RemYYYYMMDDHHmmss
case"1"
sendTime=year(sendTime)&right("00"&month(sendTime),2)&right("00"&day(sendTime),2)&right("00"&hour(sendTime),2)&right("00"&minute(sendTime),2)&right("00"&second(sendTime),2)
RemYYYYMMDD
case"2"
sendTime=year(sendTime)&right("00"&month(sendTime),2)&right("00"&day(sendTime),2)
RemYYYY-MM-DD
case"3"
sendTime=year(sendTime)&"-"&right("00"&month(sendTime),2)&"-"&right("00"&day(sendTime),2)
RemYYYY年MM月DD日
case"4"
sendTime=year(sendTime)&"年"&right("00"&month(sendTime),2)&"月"&right("00"&day(sendTime),2)&"日"
RemYYYY-MM-DDHH:mm:ss
case"5"
sendTime=year(sendTime)&"-"&right("00"&month(sendTime),2)&"-"&right("00"&day(sendTime),2)&""&right("00"&hour(sendTime),2)&":"&right("00"&minute(sendTime),2)&":"&right("00"&second(sendTime),2)
endselect
FormateDateTime=SendTime
endFunction

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: