Realstudio (2011 4.2) Date in Milliseconds

313 views Asked by At

In my project I communicate with a Microsoft SQL-Database where I have a column with DATETIMEs. The date-information in the database is with Milliseconds, that's very important, like 2012-03-03 12:00:00.364

In Java, for example, it's no problem to read the Date value from the RecordSet with Milliseconds.

In Realbasic when I do something like that time = rs.IdxField(i).DateValue the milliseconds are lost, because the Date-Object has a maximum resolution of seconds.

How can I read the SQL-Datetime with milliseconds? What can be an easy way to read it as String and then parse it or something like that?

2

There are 2 answers

0
purplesoft On

Use Convert Statement Syntax:

select CONVERT(nvarchar(30), GETDATE(), 126)

try it.

Tiz

0
mjdth On

If you already have the information in a database and are just reading from your SQL database, I'd recommend subclassing Date, adding a variable for Milliseconds, and then just manually parsing out from the period/etc to get the milliseconds value.

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) 

You could then add other functions for comparing the date subclass to include the milliseconds variable.