|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I've been having trouble comparing dates with my code, for some reason it does not return the proper responce. I have several dates stored in my mySQL database (sebclose, ebclose, regclose, and closedate), in the default format, which I'm trying to compare to a datestamp so that as people view my page, it will display the code for that time frame. The problem I'm runing into, is that responce to my IF statements are not being returned correctly. Perhapse somebody will see what I'm doing wrong and can correct it.
the dates currently are datestamp = 2004-10-15 sebclose = 0000-00-00 ebclose = 2004-09-30 regclose = 2004-10-31 closedate = 2004-10-31 $datestamp = date("Y-m-d"); if($myrow["sebhead"]!="" AND $myrow["sebclose"] >= '$datestamp' AND $myrow["sebclose"] != '0000-00-00'){Show SEBcode} if($myrow["sebclose"]!="0000-00-00" AND $myrow["sebclose"] <= '$datestamp'){ }else{ if($myrow["ebhead"]!="" AND $myrow["ebclose"] >= '$datestamp' AND $myrow["ebclose"] != '0000-00-00'){Show EBcode} if($myrow["reghead"]!="" AND $myrow["regclose"] >= '$datestamp' AND $myrow["ebclose"] < '$datestamp'){Show REGcode} if($myrow["latehead"]!="" AND $myrow["closedate"] >= '$datestamp' AND $myrow["regclose"] < '$datestamp'){Show LATEcode} Even though the server is reporting the correct date for the datestamp (2004-10-15) the if statement for EBcode is displaying and not REGcode. |
|
#2
|
||||
|
||||
|
you are putting $datestamp inside single quotes so it won't get parased.
|
|
#3
|
|||
|
|||
|
Thanks, that fixed it.
|
|
#4
|
|||
|
|||
|
why are you taking them out of sql to compare? use sql calls to compare them. compare IN SQL and you do not need to touch anything in php. that is the most efficient thing to do.
let's say you want all closed files PHP Code:
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Need help with comparing dates |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|