Convert the specified component of a DBDATETIME structure into its corresponding character string.
int dbdatename(dbproc, charbuf, datepart, datetime) DBPROCESS *dbproc; char *charbuf; int datepart; 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 character buffer that will contain the null-terminated character representation of the datetime component of interest. If datetime is NULL, charbuf will contain a zero-length string.
The date component of interest. The following table lists the date parts, the date part symbols recognized by DB-Library and the expected values. Note that the names of the months and the days in this table are those for English.
| Date part | Symbol | Character representation of value | 
|---|---|---|
| year | DBDATE_YY | 1753 – 9999 | 
| quarter | DBDATE_QQ | 1 – 4 | 
| month | DBDATE_MM | January – December | 
| day of year | DBDATE_DY | 1 – 366 | 
| day | DBDATE_DD | 1 – 31 | 
| week | DBDATE_WK | 1 – 54 (for leap years) | 
| weekday | DBDATE_DW | Monday – Sunday | 
| hour | DBDATE_HH | 0 – 23 | 
| minute | DBDATE_MI | 0 – 59 | 
| second | DBDATE_SS | 0 – 59 | 
| millisecond | DBDATE_MS | 0 – 999 | 
A pointer to the DBDATETIME value of interest.
The number of bytes placed into *charbuf.
In case of error, dbdatename returns -1.
dbdatename converts the specified component of a DBDATETIME structure into a character string.
The names of the months and weekdays are in the language of the specified DBPROCESS. If dbproc is NULL, these names will be in DB-Library’s default language.
This function is very similar to the Transact-SQL datename function.
The following code fragment illustrates the use of dbdatename:
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); 
      /* Print the parts of the creation date */ 
      dbdatename(dbproc, datestring, DBDATE_YY,  
           (DBDATETIME *) (dbdata(dbproc, 2))); 
      printf("\tYear = %s.\n", datestring); 
      dbdatename(dbproc, datestring, DBDATE_QQ,  
           (DBDATETIME *) (dbdata(dbproc, 2))); 
      printf("\tQuarter = %s.\n", datestring); 
      dbdatename(dbproc, datestring, DBDATE_MM,  
           (DBDATETIME *) (dbdata(dbproc, 2))); 
      printf("\tMonth = %s.\n", datestring); 
      dbdatename(dbproc, datestring, DBDATE_DW,  
           (DBDATETIME *) (dbdata(dbproc, 2))); 
      printf("\tDay of week = %s.\n", datestring); 
      dbdatename(dbproc, datestring, DBDATE_DD,  
           (DBDATETIME *) (dbdata(dbproc, 2))); 
      printf("\tDay of month = %s.\n", datestring); 
      dbdatename(dbproc, datestring, DBDATE_DY,  
           (DBDATETIME *) (dbdata(dbproc, 2))); 
      printf("\tDay of year = %s.\n", datestring); 
      dbdatename(dbproc, datestring, DBDATE_HH,  
           (DBDATETIME *) (dbdata(dbproc, 2))); 
      printf("\tHour = %s.\n", datestring); 
      dbdatename(dbproc, datestring, DBDATE_MI,  
           (DBDATETIME *) (dbdata(dbproc, 2))); 
      printf("\tMinute = %s.\n", datestring); 
      dbdatename(dbproc, datestring, DBDATE_SS,  
           (DBDATETIME *) (dbdata(dbproc, 2))); 
      printf("\tSecond = %s.\n", datestring); 
      dbdatename(dbproc, datestring, DBDATE_MS,  
           (DBDATETIME *) (dbdata(dbproc, 2))); 
      printf("\tMillisecond = %s.\n", datestring); 
      dbdatename(dbproc, datestring, DBDATE_WK,  
           (DBDATETIME *) (dbdata(dbproc, 2))); 
      printf("\tWeek = %s.\n", datestring);