mirror of
https://github.com/mdbtools/mdbtools.git
synced 2026-03-10 00:20:54 +08:00
Improved support for "Short Date" fields
* Separate -D (date only) and -T (date/time) format options in mdb-export and mdb-json * New public mdb_set_shortdate_fmt() function in libmdb * New private(ish) mdb_col_is_shortdate() function I'm calling it "shortdate" in order to preserve the existing API. See https://github.com/mdbtools/mdbtools/issues/12
This commit is contained in:
@@ -167,6 +167,7 @@ static SQLRETURN do_connect (
|
||||
// ODBC requires ISO format dates, see
|
||||
// https://docs.microsoft.com/en-us/sql/relational-databases/native-client-odbc-date-time/datetime-data-type-conversions-odbc?view=sql-server-ver15
|
||||
mdb_set_date_fmt( dbc->sqlconn->mdb, "%F %H:%M:%S" );
|
||||
mdb_set_shortdate_fmt( dbc->sqlconn->mdb, "%F" );
|
||||
return SQL_SUCCESS;
|
||||
}
|
||||
else
|
||||
@@ -1592,8 +1593,7 @@ SQLRETURN SQL_API SQLGetData(
|
||||
struct tm tmp_t;
|
||||
mdb_date_to_tm(mdb_get_double(mdb->pg_buf, col->cur_value_start), &tmp_t);
|
||||
|
||||
const char *format = mdb_col_get_prop(col, "Format");
|
||||
if (format && !strcmp(format, "Short Date")) {
|
||||
if (mdb_col_is_shortdate(col)) {
|
||||
DATE_STRUCT sql_dt;
|
||||
sql_dt.year = tmp_t.tm_year + 1900;
|
||||
sql_dt.month = tmp_t.tm_mon + 1;
|
||||
|
||||
Reference in New Issue
Block a user