Hi,
I am trying to use this nice module: https://github.com/coffeepots/odbc and I ran into a problem.
if field.kind == dtTime:
echo field.toString # output looks like "(milliseconds: 0, seconds: 48, minutes: 15, hours: 7, days: 31, months: 10, years: 2017)"
Is there a way to get it formatted to "normal" form like "2017-10-31 07:15:48.0" ? I can't find any way to convert "TimeInterval" type into formatted string. All procedures I've found work with "TimeInfo", but not with "TimeInterval"
Please help.
Will.
The TimeInterval is an offset to a Time (obviously). But the Time value is a number (usually representing 1970-01-01 onwards in seconds).
Your interval is actually an interval relative to the year 0 A.D. (or a date represented in TimeInterval) which if used with a Time value won't give you what you want.
So as @dom96 say, you need to convert TimeInterval to TimeInfo by hand (because your interval isn't really an interval).
if field.kind == dtTime:
tm1=getLocalTime(getTime())+field
This raises compile time error: "Error: type mismatch: got (TimeInfo, SQLData)"
It looks like there is some inconsistency with ODBC module, or (maybe) somewhere else, causing "field" to be of some incompatible type.
Your field is SQLData type and getLocalTime(getTime()) is TimeInfo, of course it wouldn't compile as you (or the module) haven't implemented the + proc.
I said so because I couldn't find any enum with value dtTime in times module.