Convert datetime between the application's and database's resolution.
mco_int8 mco_time2ticks(mco_int8 time, int scale);
| ticks | The number of time ticks since 1 Jan 1970 (Epoch) |
|
scale |
The resolution of time ticks: from 1 (second) to 1000000000 (nanoseconds) |
This function converts the argument
timeto the corresponding value specified by the resolution argumentscale.
| mco_int8 | The value of ticks converted to the resolution scale |
Schema file snippet:
class Object
{
datetime dt;
...
};
Application snippet:
int main(int argc, char* argv[])
{
...
mco_trans_start(db, MCO_READ_WRITE, MCO_TRANS_FOREGROUND, &trans);
if ( MCO_S_OK != rc )
{
mco_datetime dt;
...
T_dt_get(&obj, &dt);
printf("dt (in msecs) = %llu, dt (in usecs) = %llu\n", t, d,
mco_time2ticks(dt, 1000), mco_time2ticks(dt, 1000*1000));
...
}
}
Note that if we want to get datetime in milliseconds, we call mco_time2ticks() with 1000 as the second parameter; for microseconds the second parameter must be 1000*1000.