Closed xhit closed 4 years ago
But, what happens If I need to know if returned type is Time or Timestamp or Date for formatting and store this value in CSV, JSON, etc... and this file need integration with other systems?
If you need columns metadata see sql.Rows.ColumnTypes() method
Perfect, thanks!
Every row scanned with a date, time or timestamp is returned in interface{} and I can get the golang type time.Time and it's ok.
But, what happens If I need to know if returned type is Time or Timestamp or Date for formatting and store this value in CSV, JSON, etc... and this file need integration with other systems?
Go sql drivers I found doesn't provide this. Drivers should have a mechanism to return datetypes in a casteable format at least in the same RDBMS.
Now, why? Sometimes a custom query is sending to driver, so developer doesn't know the query because was sent by user, so the returned values are a nightmare for user and need some programming to get expected values and not Go values.
Pull request 94 have this support, test included.
Date: returned in format 2006-01-02 Time: returned in format 15:04:05.000 Timestamp: returned in format 2006-01-02 15:04:05.000
Note all formatted dates are compatible with at least all RDBMS for integration.