[HELP] datecmp
#1

Hello, im trying to make function to compare between dates.
The output should be formated string (YYYY-MM-DD), ANYWAY..
Thats what i made so far.. i've not checked it yet
But i'm feeling that something not clear with the MATH in it.

It should return number of years, months and days.
//for example. 2011/10/08 to 1993/11/15
//Output will be
//17 Years
//11 Months
// 23 Days
**As far as i know there is few months that contain 31 days~28days but there is no-way to check it and to get the correct number of the days between two dates...

Hope you'll help me to make it work perfect with the correct number of days.

stock datecmp(year, month, day)
{
new cy, cm, cd;
getdate(cy, cm, cd);

new y, m, d;
y = cy - year;

if(cm < month)
m = month - cm;
if(cm > month)
m = cm - month;

if(cd < day)
d = day - cd;
if(cd > day)
d = cd - day;

new string[12];
format(string,12,"%04d-%02d-%02d", y, m, d);
return(string);
}
Reply
#2

?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)