getdate, setdate

De RAD Studio
Aller à : navigation, rechercher

Remonter à Dos.h - Index

Header File



Time and Date Routines


void getdate(struct date *datep);

void setdate(struct date *datep);


Gets and sets system date.

getdate fills in the date structure (pointed to by datep) with the system's current date.

setdate sets the system date (month, day, and year) to that in the date structure pointed to by datep. Note that a request to set a date might fail if you do not have the privileges required by the operating system.

The date structure is defined as follows:

struct date{

int da_year; /* current year */

char da_day; /* day of the month */

char da_mon; /* month (1 = Jan) */


Return Value

getdate and setdate do not return a value.


 #include <dos.h>
 #include <stdio.h>
 int main(void)
    struct date d;
    printf("The current year is: %d\n", d.da_year);
    printf("The current day is: %d\n", d.da_day);
    printf("The current month is: %d\n", d.da_mon);
    return 0;