good day;
please spare some of your precious time with me,
i'm really having a hard time to analyze this.

my problem is how to evaluate two dates if it is not the same date.
the first date is the actualdate

$actualTime = date ('d M Y @ H:i:s', $time+28800);

the second date is from database "SELECT `date` FROM `medicalrecords` where date=`$actualTime`" therefore if query_row == 1,the condition would be true.
but my query seems not working.
note that datatype of medicalrecords.date is varchar.

sorry if I sound stupid to you im new in php.

Member Avatar for diafol

You're trying to match the time element as well?

nope just the date,

Member Avatar for diafol
$secs_add = 28000;
 list($year,$month) = explode("-",date('Y-n', time() + $secs_add));
 $r = mysql_query("SELECT ... FROM ... WHERE MONTH(`date`) = $month AND YEAR(`date`) = $year"); 
 ...

however, this assumes your mysql date format is readable, e.g. 2012-01-18...

The only formats that I can think of that should be used are the above: yyyy-mm-dd and unix timestamp (integer), or even yyyymmdd. You can easily reformat unix timestamp s and yearmonthday integers to the standard yyyy-mm-dd.

thank you for your kind heart sir ardav;
yes my mysql date format is 0000-00-00
i cant try it for now cause im in cafe.
but im having this is my mind..

$crow = mysql_num_rows($r);
if ($crow == 1) {
echo 'cant add records with same date';
}

I have a question sir, what is that MONTH and YEAR in your WHERE condition?

Member Avatar for diafol

They are mysql functions that extract parts of the date from a date string

ayayay sorry sir i was giving u the wrong information, the format of date in mysql is 20 Jan 2012
is there also a DAY function sir?

because my goal is to prevent the user for a day to enter a record if 4 of values is already existing in the specified fields (one of this is the date field)

Member Avatar for diafol

This date format IMO should not be used as the recordset cannot be ordered and date functions such as DAY and MONTH will not work with it. Yes there is also a day function. If you are using mysql you really should try reading the online manual.

problem solve: thank you sir ardav i wish i could send u a beer..
heres what I did..

$comTime = date ('d M Y', $time+28800);
$queryeval = "SELECT `admissionId` FROM `medicalrecords` WHERE `studentsId`='$patient' AND                                           `diagnosisId`='$diagnosis' AND `date` LIKE '$comTime%'"; 
$queryeval_run = mysql_query($queryeval);
$num_rows = mysql_num_rows($queryeval_run);
							
if ($num_rows == 1) {
$comTime = date ('d M Y', $time+28800);
echo '<br><strong><font color="red" size="1px">'.$row_rsStudentsId['studentsLastName'].", ".$row_rsStudentsId['studentsFirstName']." ". '<br>is already checkup today<br>with the same diagnostic</font></strong>';	
}

sir I have a question again, is there a except function in where condition?

Member Avatar for diafol

OK, mark thread solved (link below).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.