Convert a machine-readable DBDATETIME value into user-accessible format.
RETCODE dbdatecrack(dbproc, dateinfo, datetime) DBPROCESS *dbproc; DBDATEREC *dateinfo; DBDATETIME *datetime;
A pointer to the DBPROCESS structure that provides the connection for a particular front-end/server process. It contains all the information that DB-Library uses to manage communications and data between the front end and server.
A pointer to a DBDATEREC structure to contain the parts of datetime. DBDATEREC is defined as follows:
typedef struct dbdaterec
{
long dateyear; /* 1900 to the future */
long datemonth; /* 0 - 11 */
long datedmonth; /* 1 - 31 */
long datedyear; /* 1 - 366 */
long datedweek; /* 0 - 6 */
long datehour; /* 0 - 23 */
long dateminute; /* 0 - 59 */
long datesecond; /* 0 - 59 */
long datemsecond; /* 0 - 997 */
long datetzone; /* 0 - 127 */
} DBDATEREC;
Month and day names depend on the national language of the DBPROCESS. To retrieve these, use dbdatename or dbdayname plus dbmonthname.
The dateinfo->datetzone field is not set by dbdatecrack.
A pointer to the DBDATETIME value of interest.
SUCCEED or FAIL.
dbdatecrack converts a DBDATETIME value into its integer components and places those components 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 300th’s of a second since midnight, and a date value is stored as the number of days since January 1, 1900. dbdatecrack converts the internal value to something more usable by an application program.
The integer date parts placed in the DBDATEREC structure may be converted to character strings using dbdatechar.
Calling dbdatecrack to convert an internal format datetime value is equivalent to calling dbdatepart many times.
The following code fragment illustrates the use of 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),
SYBCHAR, 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.dateyear);
printf("\tMonth = &d.\n",dateinfo.datemonth);
printf("\tDay of month = &d.\n",
dateinfo.datedmonth);
printf("\tDay of year = &d.\n",
dateinfo.datedyear);
printf("\tDay of week = &d.\n",
dateinfo.datedweek);
printf("\tHour = &d.\n", dateinfo.datehour);
printf("\tMinute = &d.\n",
dateinfo.dateminute);
printf("\tSecond = &d.\n",
dateinfo.datesecond);
printf("\tMillisecond = &d.\n",
dateinfo.datemsecond);
}