# mco_ticks2time
RT

> Convert datetime between the application's and database's resolution.

### Prototype

        mco_int8 mco_ticks2time(mco_int8 ticks, int scale);

### Arguments

ticks | The number of time ticks since 1 Jan 1970 (Epoch)
scale | The resolution of time ticks: from 1 (second) to 1000000000 (nanoseconds)

### Description

> This function converts the argument `ticks` to the corresponding value specified by the resolution argument `scale`.

### Return Value

mco_int8 | The value of `ticks` converted to the resolution `scale`

### Example

        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 )
            {
                Object obj = T_new( trans, &obj );
                rc = Object_dt_put( &obj, mco_ticks2time(mco_system_get_current_time(), 1000*1000));
                ...
            }
        }

Note that here the second argument of `mco_ticks2time()` is `1000*1000`, because `mco_system_get_current_time()` returns time in microseconds.

Related Topics

### Files

Header file:
mcotime.h
Source file:
mcodb.c
Library:
libmcolib.a
Header file:
mcotime.h
Source file:
corestub.c
Library:
libmcorsqlstub.a