0
how to compare dates in c++
4 Respuestas
+ 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?