how can i compare 2 days
example
date1=22:06:2007;
date2=23:06:2007;
how can i compare two dates
thank u
sree
how can i compare 2 days
example
date1=22:06:2007;
date2=23:06:2007;
how can i compare two dates
thank u
sree
See the functions in time.h. Here's what the FAQ from this site says about dates and times:
http://faq.cprogramming.com/cgi-bin/...&id=1043284392
BTW, you're talking about the comparison of two dates.... compassion has a meaning related to love, mercy, and perhaps pity.
thank u for u r reply
i already seen tht tutorial.
but i didn't found any function for date.
You should look slightly closer at it since you should be able to do what you want with the functions in time.h. I would also suggest you search the forums since this subject has come up before.
i searched the forum i didn't get any help.
i tried like this
struct tm ctime,ptime;
int y,m,d,y1,m1,d1;
sscanf("23:06:2007", "%od:%od:%od", &y, &m, &d);
ctime.tm_year=y;
ctime.tm_mday=d;
ctime.tm_mon=m;
sscanf("22:06:2007", "%od:%od:%od", &y1, &m1, &d1);
ptime.tm_year=y1;
ptime.tm_mday=d1;
ptime.tm_mon=m1;
time_t now1,now2;
now1=mktime(&ctime);
now2=mktime(&ptime);
g_print("***************** %d \n",difftime(now2,now1));
but it's output is "0".
thanks
%od isn't a valid scanf format.
%d isn't a valid format for printing a floating point value.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
thank u
so please tell me wht should i do.
with what character i should replace "%0d"
with a "%d". I just hope your teacher didnt teach u to put a " 0 " there.
In the middle of difficulty, lies opportunity
yah i know .
but can u tell me how we can compare dates
Well, using the difftime would u cant compare dates. It will return values in seconds. Which is not useful is it?
What u can go is, you can compare each values manually.
ssharish2005
ok thank u for ur replyyy
take the years months and days as separated items. then, compare first the years and if they are similar then months then the days
proud to be from aui www.aui.ma and also a great elton john's fan