> how can i use unix timestamp as a data type? the datetime data type should work. you can find info about it at http://www.postgresql.org/idocs/index.php?functions-datetime.html http://www.postgresql.org/idocs/index.php?datatype-datetime.html here is some example code CREATE TABLE test ( id integer PRIMARY KEY, mytime datetime ); #include <time.h> ... time_t mytime = time (NULL); printf ("time to be inserted into database: %s\n", ctime (&mytime)); /* insert row setting the time. if you want to insert the current time you can pass 'now' to a datetime field */ sprintf (sql_str, "INSERT INTO test (id, mytime) VALUES (1, '%s')", ctime (&mytime)); res = PQexec(dbconn, sql_str); ... /* get row extracting the time since the epoch */ sprintf (sql_str, "SELECT id, extract (epoch from mytime) FROM test WHERE oid = %d", PQoidValue(res)); ... mytime = atoi(PQgetvalue(res, 0, 1)); printf ("time retrieved from database: %s\n", ctime(&mytime)); ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://www.postgresql.org/search.mpl