Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server Realstudio(2011 4.2)日期(毫秒)_Sql Server_Realbasic_Realstudio - Fatal编程技术网

Sql server Realstudio(2011 4.2)日期(毫秒)

Sql server Realstudio(2011 4.2)日期(毫秒),sql-server,realbasic,realstudio,Sql Server,Realbasic,Realstudio,在我的项目中,我与一个Microsoft SQL数据库进行通信,其中有一列带有日期时间。数据库中的日期信息以毫秒为单位,这非常重要,如2012-03-03 12:00:00.364 例如,在Java中,用毫秒从记录集中读取日期值是没有问题的 在Realbasic中,当我执行类似于time=rs.IdxField(I).DateValue的操作时,毫秒将丢失,因为日期对象的最大分辨率为秒 如何以毫秒读取SQL日期时间?有什么简单的方法可以将其读取为字符串,然后解析它或类似的内容?使用Convert

在我的项目中,我与一个Microsoft SQL数据库进行通信,其中有一列带有日期时间。数据库中的日期信息以毫秒为单位,这非常重要,如
2012-03-03 12:00:00.364

例如,在Java中,用毫秒从记录集中读取日期值是没有问题的

在Realbasic中,当我执行类似于
time=rs.IdxField(I).DateValue的操作时,毫秒将丢失,因为日期对象的最大分辨率为秒

如何以毫秒读取SQL日期时间?有什么简单的方法可以将其读取为字符串,然后解析它或类似的内容?

使用Convert语句 语法:

选择CONVERT(nvarchar(30),GETDATE(),126)

试试看

Tiz

使用Convert语句 语法:

选择CONVERT(nvarchar(30),GETDATE(),126)

试试看


Tiz

如果数据库中已经有了这些信息,并且只是从SQL数据库中读取,我建议对Date进行子类化,添加一个毫秒变量,然后手动解析period/etc以获取毫秒值

dim d as new DateWithMilliseconds
d=rs.IdxField(i).DateValue

////and then however you'd parse out the milliseconds based on the string format
d.milliseconds=NthField(rs.idxField(i).stringvalue,".",2) 

然后,您可以添加其他函数来比较date子类,以包括毫秒变量。

如果您已经在数据库中有了信息,并且正在从SQL数据库中读取,我建议将date子类化,添加毫秒变量,然后从period/etc中手动解析出毫秒值

dim d as new DateWithMilliseconds
d=rs.IdxField(i).DateValue

////and then however you'd parse out the milliseconds based on the string format
d.milliseconds=NthField(rs.idxField(i).stringvalue,".",2) 
然后,您可以添加其他函数来比较date子类,以包括毫秒变量