![]() | ![]() |
Home |
|
|
Open Client DB-Library/C Reference Manual |
|
| Chapter 2: Routines |
|
| dbdatecrack |
Convert a machine-readable DBDATETIME value into user-accessible format.
RETCODE dbdatecrack(dbproc, dateinfo, datetime)
DBPROCESS *dbproc;
DBDATEREC *dateinfo;
DBDATETIME *datetime;
dbproc - 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.
dateinfo - 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.
Note: The dateinfo->datetzone field is not set by dbdatecrack.
datetime - A pointer to the DBDATETIME value of interest.
SUCCEED or FAIL.
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);
}
dbconvert, dbdata, dbdatechar, dbdatename, dbdatepart
|
|