Skip to content

Commit

Permalink
Implement ODBC conversions from big(date)time to character
Browse files Browse the repository at this point in the history
These conversions are different from libTDS ones.
Use ODBC format for date/times.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
  • Loading branch information
freddy77 committed Sep 21, 2015
1 parent 56009f3 commit 25ff091
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/odbc/convert_tds2sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,23 +354,35 @@ odbc_tds2sql(TDS_STMT * stmt, TDSCOLUMN *curcol, int srctype, TDS_CHAR * src, TD
if (desttype == SQL_C_CHAR || desttype == SQL_C_WCHAR) {
char buf[48];
TDSDATEREC when;
int prec = 3;
int prec;
const char *fmt = NULL;
const TDS_DATETIMEALL *dta = (const TDS_DATETIMEALL *) src;

switch (srctype) {
case SYBMSDATETIMEOFFSET:
case SYBMSDATETIME2:
prec = dta->time_prec;
goto datetime;
case SYB5BIGDATETIME:
prec = 6;
goto datetime;
case SYBDATETIME:
fmt = "%Y-%m-%d %H:%M:%S.%z";
break;
prec = 3;
goto datetime;
case SYBDATETIME4:
fmt = "%Y-%m-%d %H:%M:%S";
prec = 0;
datetime:
fmt = "%Y-%m-%d %H:%M:%S.%z";
break;
case SYBMSTIME:
prec = dta->time_prec;
goto time;
case SYB5BIGTIME:
prec = 6;
goto time;
case SYBTIME:
prec = 3;
time:
fmt = "%H:%M:%S.%z";
break;
case SYBMSDATE:
Expand Down

0 comments on commit 25ff091

Please sign in to comment.