Re: [PHP-DB] date comparison

2002-08-21 Thread Jason Wong

On Wednesday 21 August 2002 21:28, Smita Manohar wrote:
 hello,
 in my script i want to compare input date with date stored in database and
 want the result for date = input date and sometime for date = input date.

How is the date stored? What type of field?

 it didn't work for = and = operators. i also tried using between but it
 didn't give desire result :-(

How are you doing your comparison? As php code? As sql query?

 is there any other comparison operator to be used for date???

, =, , = can all be used if your data is in the correct format.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
Oh, yeah, life goes on, long after the thrill of livin' is gone.
-- John Cougar, Jack and Diane
*/


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




RE: [PHP-DB] Date comparison problem

2002-07-11 Thread Gabor Niederlaender

But I would like to do it the other way round. I mean for the solution
you have mentioned, I have to make the query on the whole record, then
compare the two dates and filter the right ones. I'd like to make the
query look like:

SELECT something FROM table WHERE datetime  $form_date

So I think I have to adjust the form of my $form_date.

Or am I making a mistake somewhere?

Thanx
Gabor

---
 This is how I do it:
 
 date(m/d/Y,strtotime(odbc_result($rs,ts)))
 
 where $rs is the result set and ts is the name of the field
containing the datetime.
 
  Ryan
 
 -Original Message-
 From: Gabor Niederlaender [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 10, 2002 8:21 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Date comparison problem
 
 
 Hi all!
 
 I have got a datetime field in a MS-SQL DB, and I have a date
 field in my html-form with the format: DD/MM/.
 
 I would like to compare the two, but I think the two formats are a
bit
 different and they do not really want to be compared:)
 
 If I write a query to write out the datetime field from the DB, I
 get the form :
 
 02 05 2002 12:25 
 
 In the HTML-form it looks a bit different: 12/10/2000
 
 I do not really want to explode the form-data and than build a new
 timestamp, it has to be a more simple way.
 
 Thanks, best regards
 
 Gabor
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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




RE: [PHP-DB] Date comparison problem

2002-07-11 Thread joakim . andersson

Hi,

Assuming your dates have the format you specified and that you only want to
compare dates, not time aswell.

$str_sql = SELECT something FROM mytable WHERE LEFT(my_datetime, 10) = ' .
str_replace(/,  , $form_date) . ';
or if day / month is reversed in MSSQL
$str_sql = SELECT something FROM mytable WHERE LEFT(my_datetime, 10) = ' .
substr($form_date, 3, 2) .   . substr($form_date, 0, 2) .   .
substr($form_date, 6, 4) . ';

Regards
Joakim Andersson


 -Original Message-
 From: Gabor Niederlaender [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 11, 2002 8:36 AM
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Date comparison problem
 
 
 But I would like to do it the other way round. I mean for the solution
 you have mentioned, I have to make the query on the whole record, then
 compare the two dates and filter the right ones. I'd like to make the
 query look like:
 
 SELECT something FROM table WHERE datetime  $form_date
 
 So I think I have to adjust the form of my $form_date.
 
 Or am I making a mistake somewhere?
 
 Thanx
 Gabor
 
 ---
  This is how I do it:
  
  date(m/d/Y,strtotime(odbc_result($rs,ts)))
  
  where $rs is the result set and ts is the name of the field
 containing the datetime.
  
   Ryan
  
  -Original Message-
  From: Gabor Niederlaender [mailto:[EMAIL PROTECTED]]
  Sent: Wednesday, July 10, 2002 8:21 AM
  To: [EMAIL PROTECTED]
  Subject: [PHP-DB] Date comparison problem
  
  
  Hi all!
  
  I have got a datetime field in a MS-SQL DB, and I have a date
  field in my html-form with the format: DD/MM/.
  
  I would like to compare the two, but I think the two formats are a
 bit
  different and they do not really want to be compared:)
  
  If I write a query to write out the datetime field from the DB, I
  get the form :
  
  02 05 2002 12:25 
  
  In the HTML-form it looks a bit different: 12/10/2000
  
  I do not really want to explode the form-data and than build a new
  timestamp, it has to be a more simple way.
  
  Thanks, best regards
  
  Gabor
  
  -- 
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
  
  -- 
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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




RE: [PHP-DB] Date comparison problem

2002-07-10 Thread Ryan Jameson (USA)

This is how I do it:

date(m/d/Y,strtotime(odbc_result($rs,ts)))

where $rs is the result set and ts is the name of the field containing the datetime.

 Ryan

-Original Message-
From: Gabor Niederlaender [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 10, 2002 8:21 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Date comparison problem


Hi all!

I have got a datetime field in a MS-SQL DB, and I have a date
field in my html-form with the format: DD/MM/.

I would like to compare the two, but I think the two formats are a bit
different and they do not really want to be compared:)

If I write a query to write out the datetime field from the DB, I
get the form :

02 05 2002 12:25 

In the HTML-form it looks a bit different: 12/10/2000

I do not really want to explode the form-data and than build a new
timestamp, it has to be a more simple way.

Thanks, best regards

Gabor

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


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