While Not rowsFound.AfterLastRow
KDate = row.Column("pur_date").DateTime
rowsFound.MoveToNextRow
Wend
rowsFound.Close // You can leave that one out. rowsFound will be trashed after you have left the Method/Event ;)
var rowsFound As RowSet
var KDate as DateTime
var sql as string
sql = “SELECT appname, pur_date FROM license”
Try
rowsFound = MyDB.SelectSQL(sql)
If rowsFound <> Nil Then
While Not rowsFound.AfterLastRow
if rowsFound.Column("pur_date").StringValue.Length > 9 then
KDate = rowsFound.Column("pur_date").DateTimeValue
end if
rowsFound.MoveToNextRow
Wend
system.DebugLog "Date: " + KDate.SQLDateTime
End if
Catch error as DatabaseException
MessageDialog.Show( CurrentMethodName + " - Error: " + error.Message )
End Try
No, it works just fine if the Column is really a DateTime Column.
But, if the Column is just a VarChar/String Column which contains DateTime Strings, why not just do a KDate = DateTime.FromString( rowsFound.Column("pur_date").StringValue ) ?
As long as you are catching Exceptions and handling them accordingly, you should be fine.
He knows the Types. I think he expected that the autoconversion from String to DateTime was a valid one, but It’s not. But in this case, the FromString Method can be helpfull.
If the first example we have these items:
rowsFound As RowSet
row as DatabaseRow
A DatabaseRow has these values
BlobColumn
BooleanColumn
Column
CurrencyColumn
DateColumn
DateTimeColumn
DoubleColumn
Int64Column
IntegerColumn
PictureColumn
All these value a working except DateColumn and DateTimeColumn. My field in the database is a DateTime field.
In the second example we have these items:
rowsFound As RowSet
rowsFound.Column as DatabaseColumn
rowsFound.Column has the same values like row in the first example, because it is the same type.
The difference is this:
Example
KDate = row.DateTimeColumn(“pur_date”)
Example
KDate = rowsFound.Column(“pur_date”).DateTimeValue
I don’t know why I can use .DateTimeValue in rowsFound.Column, but not in row.DateTimeColumn or row.Column. Why row.Column(“pur_date”). has only the values?
CLong
Encoding
Split
ToArray
ToInt64
TotText