Re: [PHP-DB] CONVERT STRING VARIABLES TO DATES, THEN COMPARE (HOW?)

2003-11-07 Thread Karen Resplendo

Education  :)

(it seems like such a simple thing to do, to look up, to have in someone's library of 
code, yet. . . . . . .)



> I can do it with my eyes closed in SQL. I don't want to if I can avoid it.

It's more efficient to do so, so can I ask why you want to avoid it?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
A truth that's told with bad intent
Beats all the lies you can invent.
-- William Blake
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard

Re: [PHP-DB] CONVERT STRING VARIABLES TO DATES, THEN COMPARE (HOW?)

2003-11-07 Thread Jason Wong
On Saturday 08 November 2003 03:08, Karen Resplendo wrote:
> Yes, the values echo out the way I expect them. But these are displayed
> values, not dates, I'm pretty sure, and that is why the comparison is
> failing.
>
> The question began very simply. I will try to make it simpler:
>
> How do I compare a string date from a database to today's date using PHP?

The proper way would be to convert both to unix timestamps then a simple 
greater-than or equal-to comparison would suffice.

> I can do it with my eyes closed in SQL. I don't want to if I can avoid it.

It's more efficient to do so, so can I ask why you want to avoid it?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
A truth that's told with bad intent
Beats all the lies you can invent.
-- William Blake
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] CONVERT STRING VARIABLES TO DATES, THEN COMPARE (HOW?)

2003-11-07 Thread Karen Resplendo
Yes, the values echo out the way I expect them. But these are displayed values, not 
dates, I'm pretty sure, and that is why the comparison is failing.
 
The question began very simply. I will try to make it simpler:
 
How do I compare a string date from a database to today's date using PHP?
I can do it with my eyes closed in SQL. I don't want to if I can avoid it.
 
 

Jason Wong <[EMAIL PROTECTED]> wrote:
On Saturday 08 November 2003 02:44, Karen Resplendo wrote:
> Apache on NT using MS SQL Srvr 2000
> PHP 4.03pl1
>
> I return these dates into strings and now I want to compare my database
> date to see if it is later than today's date. Pretty sure my "Expires"
> field is a string:
>
> Here is the "Expires" field from the SQL:
> Convert(varchar, DATEADD(Year,3,DateCertified),101) AS Expires
>
> Here is my PHP code trying to compare dates:
>
> $today = date("m/d/Y");
>
> If ($today < odbc_result($data,"Expires"))
> {
> echo "

License has expired

";
> }
> Else
> {
> echo "

License has not expired

";
> }
>
> Sure could use a simple solution to a simple problem that has me simply
> confounded.

Why not just do the comparison directly within the query?

And if you want to get the above working, have you tried debugging it?

Like:

print($today);
print(odbc_result($data,"Expires"));

Are they what you expected them to be?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
Alaska:
A prelude to "No."
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard

Re: [PHP-DB] CONVERT STRING VARIABLES TO DATES, THEN COMPARE (HOW?)

2003-11-07 Thread Jason Wong
On Saturday 08 November 2003 02:44, Karen Resplendo wrote:
> Apache on NT using MS SQL Srvr 2000
> PHP 4.03pl1
>
> I return these dates into strings and now I want to compare my database
> date to see if it is later than today's date. Pretty sure my "Expires"
> field is a string:
>
> Here is the "Expires" field from the SQL:
> Convert(varchar, DATEADD(Year,3,DateCertified),101) AS Expires
>
> Here is my PHP code trying to compare dates:
>
> $today = date("m/d/Y");
>
>If ($today < odbc_result($data,"Expires"))
> {
>  echo "License has expired";
> }
>Else
> {
>  echo "License has not expired";
> }
>
> Sure could use a simple solution to a simple problem that has me simply
> confounded.

Why not just do the comparison directly within the query?

And if you want to get the above working, have you tried debugging it?

Like:

 print($today);
 print(odbc_result($data,"Expires"));

Are they what you expected them to be?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
Alaska:
A prelude to "No."
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] CONVERT STRING VARIABLES TO DATES, THEN COMPARE (HOW?)

2003-11-07 Thread Oscar Rylin
Strtotime()
Look it up in the manual :-)

-Original Message-
From: Karen Resplendo [mailto:[EMAIL PROTECTED] 
Sent: den 7 november 2003 19:44
To: [EMAIL PROTECTED]
Subject: [PHP-DB] CONVERT STRING VARIABLES TO DATES, THEN COMPARE (HOW?)

Apache on NT using MS SQL Srvr 2000
PHP 4.03pl1
 
I return these dates into strings and now I want to compare my database date
to see if it is later than today's date. Pretty sure my "Expires" field is a
string:
 
Here is the "Expires" field from the SQL:
Convert(varchar, DATEADD(Year,3,DateCertified),101) AS Expires
 
Here is my PHP code trying to compare dates:
 
$today = date("m/d/Y");
 
   If ($today < odbc_result($data,"Expires"))
{
 echo "License has expired";
}
   Else
{
 echo "License has not expired";
}
 
Sure could use a simple solution to a simple problem that has me simply
confounded.
 
 


-
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php