UFT 不会从 SQL 获取毫秒数

UFT doesnt get milliseconds from SQL

正在尝试从 MS SQL 获取时间。数据库中的时间格式为MM/DD/YYY hh:mm:ss.mls。 通过 UFT 读取时,它获取的时间没有毫秒,但以毫秒为单位四舍五入,即如果它是 1:48:33.724,UFT 给出 1:48:34,如果它是 1:48:33.245,UFT 给出 1:48:33 . 如何避免舍入并获得全时格式?

如评论所述,我不得不将查询修改为 return 毫秒。我修改为:

SELECT p.Name, P.Description,p.Share, e.Name, p.OpenSDate, p.OpenEDate, p.EffectiveDate, p.CreatedBy, CAST(p.CreateDate AS datetime2(3)) AS 'CreateDate', p.DeativedBy, CAST(p.DeactiveDate AS datetime2(3)) AS 'DeactiveDate' FROM [tblProgram] p inner join [tblMapping] pm on p.ProgramID = pm.ProgramID inner join [tblEntity] e on pm.EntityID = e.EntityID order by 1,4

最初,数据库有 3 个数字表示毫秒,所以我使用 datetime2(3)。在 UFT 中,我只是拆分了它:

dbDate = CDate(Split(dbCellData, ChrW(32))(0)) 'this gives the date part
longtime = Split(dbCellData, ChrW(32))(1) 'this gives the time part with milliseconds
dbtime = Split(longtime, ".")(0) 'this gives time without milliseconds but not rounded

转介:https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime2-transact-sql