Re: datetime data
Posted in 1993
gm0564@swuts.sbc.com (George Ma) writes: > Has any one had experience to retrieve datetime type data into sqlda and then > to convert it into char string using dttoasc()? > I tried but dttoasc() failed to provide correct data. > > I wonder whether datetime type data has to be FETCHed INTO a host variable of > type dtime_t but cannot be loaded into sqlda since there is no way to > initialize dt_qual field if sqlda is used? Hint: According to the ESQL/C Programmers manual 4.00 p. 2-26 sqllen is the qualifier for a fetched dtime_t or intrvl_t. Initialise the dtime_t.dt_qual from the sqllen, or set it to zero (I haven't tried this - just read about it) > Thanks in advanced for any information. Alternatively, there's an easier solution: change the sqltype from SQLDTIME to SQLCHAR and change the sqllen to a length long enough to hold the string representation of the datetime (and allocate that much buffer space,) then let the fetch do the conversion for you. I know this works 'cos that's how I do it. This conversion actually works for any SQL datatype except BLOBs, provided there's enough space (sqllen big enough and buffer allocated.) =========================================================================== | Bill Hails <bill@tardis.co.uk> | | | C.L.I. Connect Ltd. | README: permission denied | | 19, Quarry St., Guildford, Surrey | | | GU1 3UY. Tel (UK) 0483 300 200 | | ===========================================================================