Justman
|
| Posted: 01/07/2005, 2:25 AM |
|
Hi All,
I want to compare today's date to a date from database in custom code. I don't want to diplay the dates to the user so design setting of labels or text boxes is not required.
But the code kept failing because the date fromthe database is being returned as Array:
// Get today's date
$this_day = date("d-m-Y"); // This works well
//Get the date from database
$due_date = CCDLookUp("expiration_date", "date_table", "serial_sec_num_id =" .
$DBConn->ToSQL($serial_num_original , ccsInteger), $DBConn );
due_date2 = CCParseDate($due_date, Array("yyyy", "-", "mm", "-", "dd", " ", "HH", ":", "nn", ":", "ss", ".", "S")); // This returns Array!
Please let me know if you have any suggestions.
Cheers,
Justman
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 01/07/2005, 9:48 AM |
|
I'm not sure why are you using CCParseDate.
Doesn't $due_date already contain your date returned by CCDLookup?
And depending on the time format returned by your database you should be able to use any PHP date functions: http://us4.php.net/datetime
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
Justman
|
| Posted: 01/07/2005, 12:28 PM |
|
Hi Peter,
Thanks for your response.
If I use $due_date as it came from the database, it gives me 31/12/1969.
I am not after someone else's date of birth (don't laugh). I just want to get exactly the date as it exists in the database.
Chers,
Justman
Quote peterr:
I'm not sure why are you using CCParseDate.
Doesn't $due_date already contain your date returned by CCDLookup?
And depending on the time format returned by your database you should be able to use any PHP date functions: http://us4.php.net/datetime
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 01/07/2005, 12:46 PM |
|
OK, but CDLookUp doesn't convert anything. All it does it returns data based on your SQL statement . You can look at the CCDLookUp code in Common.php to see how simple it is - just one line of code. So the point is that you are getting exactly the date as it exists in the database.
What happens if you run your query directly in your database without PHP?
Or, do you get anything with this query?:
SELECT expiration_date FROM date_table WHERE expiration_date = '31/12/1969'
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
|