Subject Re: [ib-support] Timestamp and CURRENT_TIMESTAMP resolution
Author Arno Brinkman
Hi,

> Hello all.
>
> Does anybody know why CURRENT_TIMESTAMP returns values rounded to
> seconds? How to get microseconds also?

Maybe someone can take a look on the source and could explain why :
I'm not so familar with C but i think the "isc_encode_sql_time" routine
explains it.
It seems that the time-structure only can hold 0..59 officialy ?

-------------
case nod_current_timestamp:
{
<snip>
isc_encode_timestamp (×, &enc_times);
<snip>
}
return &impure->vlu_desc;
-------------
#define ISC_TIME_SECONDS_PRECISION 10000L
#define ISC_TIME_SECONDS_PRECISION_SCALE -4
----------------
void API_ROUTINE isc_encode_sql_time (
void *times_arg,
GDS_TIME *isc_time)
{
struct tm *times;

times = (struct tm*) times_arg;
*isc_time = ((times->tm_hour * 60 + times->tm_min) * 60 +
times->tm_sec) * ISC_TIME_SECONDS_PRECISION;
}
----------------
struct tm {
int tm_sec; /* seconds after the minute - [0,59] */
int tm_min; /* minutes after the hour - [0,59] */
int tm_hour; /* hours since midnight - [0,23] */
int tm_mday; /* day of the month - [1,31] */
int tm_mon; /* months since January - [0,11] */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday - [0,6] */
int tm_yday; /* days since January 1 - [0,365] */
int tm_isdst; /* daylight savings time flag */
};
#define _TM_DEFINED
----------------

Regards,
Arno