1

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?

Flexo
  • 87,323
  • 22
  • 191
  • 272

2 Answers2

1

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.

mjdth
  • 6,536
  • 6
  • 37
  • 44
0

Use Convert Statement Syntax:

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

try it.

Tiz

purplesoft
  • 516
  • 2
  • 10