0
how to compare dates in c++
4 Answers
+ 8
use like this:
#include<stdio.h>
#include<conio.h>
struct date
{
int day;
int month;
int year;
};
void main()
{
struct date d1,d2;
clrscr();
printf(âEnter first date(dd/mm/yyyy):â);
scanf(â%d%d%dâ,&d1.day,&d1.month,&d1.year);
printf(ânEnter second date(dd/mm/yyyy):â);
scanf(â%d%d%dâ,&d2.day,&d2.month,&d2.year);
if((d1.day==d2.day)&&(d1.month==d2.month)&&(d1.year==d2.year))
printf(ânEQUALâ);
else
printf(ânUNEQUALâ);
getch();
}
+ 1
if you have dates in the form of dd:mm:yy. first compare year, if years are same, then compare months and at last day.
+ 1
You need to compare a recorded date to the current date? Is this what you are asking?
0
I need to get the difference in the amount of 10 months. how to do it?