Converts a machine-readable DBDATETIME value into user-accessible format.
RETCODE dbdatecrack (
PDBPROCESS dbproc,
LPDBDATEREC dateinfo,
LPCDBDATETIME datetime );
where
typedef struct dbdaterec { int year; // 1753 - 9999 int quarter; // 1 - 4 int month; // 1 - 12 int dayofyear; // 1 - 366 int day; // 1 - 31 int week; // 1 - 54 (for leap years) int weekday; // 1 - 7 (Mon. - Sun.) int hour; // 0 - 23 int minute; // 0 - 59 int second; // 0 - 59 int millisecond; // 0 - 999 } DBDATEREC;
SUCCEED or FAIL.
dbdatecrack converts a DBDATETIME value into its integer components and puts them into a DBDATEREC structure.
DBDATETIME structures store date and time values in an internal format. For example, a time value is stored as the number of 300ths of a second since midnight, and a date value is stored as the number of days since January 1, 1900. The dbdatecrack function converts the internal value to something easily usable by an application.
The following code fragment shows how to use dbdatecrack:
dbcmd(dbproc, "select name, crdate from master..sysdatabases"); dbsqlexec(dbproc); dbresults(dbproc); while (dbnextrow(dbproc) != NO_MORE_ROWS) { // Print the database name and its date info dbconvert(dbproc, dbcoltype(dbproc, 2), dbdata(dbproc, 2), dbdatlen(dbproc, 2), SQLCHAR, datestring, -1); printf("%s: %s\n", (char *) (dbdata(dbproc, 1)), datestring); // Break up the creation date into its constituent parts dbdatecrack(dbproc, &dateinfo, (DBDATETIME *) (dbdata(dbproc, 2))); // Print the parts of the creation date printf("\tYear = &d.\n", dateinfo.year); printf("\tMonth = &d.\n", dateinfo.month); printf("\tDay of month = &d.\n", dateinfo.day); printf("\tDay of year = &d.\n", dateinfo.dayofyear); printf("\tDay of week = &d.\n", dateinfo.weekday); printf("\tHour = &d.\n", dateinfo.hour); printf("\tMinute = &d.\n", dateinfo.minute); printf("\tSecond = &d.\n", dateinfo.second); printf("\tMillisecond = &d.\n", dateinfo.millisecond); }