[PHP-DB] Date problem with new year

2002-01-02 Thread Faye Keesic

I have a db site that always displays the most recent occurrence of news
stories

The last occurrence of stories was last year (2001-12-31) and up to the new
year rolling over, I had no difficulty subtracting days, etc.

Is there a bug in Mysql?  PHP that I don't know of..

Please help.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Date problem with new year

2002-01-02 Thread Rick Emery

No bug, mate.

Post your code so that we can help ya...

-Original Message-
From: Faye Keesic [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 02, 2002 8:56 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Date problem with new year


I have a db site that always displays the most recent occurrence of news
stories

The last occurrence of stories was last year (2001-12-31) and up to the new
year rolling over, I had no difficulty subtracting days, etc.

Is there a bug in Mysql?  PHP that I don't know of..

Please help.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Date problem with new year

2002-01-02 Thread ted

Did you convert the dates to PHP's Julian format before subtracting?

On Wed, 2 Jan 2002, Faye Keesic wrote:

 I have a db site that always displays the most recent occurrence of news
 stories

 The last occurrence of stories was last year (2001-12-31) and up to the new
 year rolling over, I had no difficulty subtracting days, etc.

 Is there a bug in Mysql?  PHP that I don't know of..

 Please help.


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Date problem with new year

2002-01-02 Thread Faye Keesic

Okay, when I try to change the gregorian date to julian, I get
error: call to undefined function: gregoriantojd() in line...

Here's the code I used to replace $datetoget=($datetoget-1);

//from what I understand ,must be in month, day, year format
//so passed today's date
$greg_date=GregorianToJD(1,2,2002);
//subtracted a day
$greg_date=($greg_date-1);
//converted it back to gregorian format
$datetoget=JDToGregorian($greg_date);
-- 
Faye Keesic
Computer Programmer Analyst/Web Page Design


 From: [EMAIL PROTECTED]
 Date: Wed, 2 Jan 2002 07:55:02 -0800 (PST)
 To: Faye Keesic [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] Date problem with new year
 
 Ah... the $datetoget = ($datetoget-1) is the problem.
 
 Convert the Gregorian Ymd date to Julian, subtract 1, then convert the
 Julian date back to Gregorian (or Hebrew ;-).  I've not had much success
 with MySQL's date functions.
 
 On Wed, 2 Jan 2002, Faye Keesic wrote:
 
 I had no problems with retrieving news stories from previous days before
 2002, and haven't changed any of my code.  This site has been up for a year,
 and I can't recall anything like this happening when 2001 rolled around.
 
 Please excuse the messy code, as this was the first php/db web site I
 designed. I took out the formatting stuff...  :)
 
 From my php page, I call a function:
 
 get_most_recent_stories(date(Ymd));
 - which passes today's date, formatted for for the db
 
 In my code:
 
 - this is the function I call - which in turn calls the function below
 (no_yesterdays_stories($datetoget) to subtract a day if there is no news
 items for the current date, which then calls the same
 get_most_recent_stories() function, but passes a lower date. Ideally,
 these will loop until there are stories found for a certain day.
 
 
 function get_most_recent_stories($datetoget)
 
 {
 //Get the headlines, summaries and links to the story
 db_connect();
 $sql = SELECT * FROM tblStory WHERE (StoryDate=$datetoget);
 $results = mysql_query($sql);
 if ($results) {
 if ($row = mysql_fetch_array($results)) {
 echo $row[StorySum];}
 while ($row = mysql_fetch_array($results));
 }
 else {
 no_yesterdays_stories($datetoget); } }
 }
 
 function no_yesterdays_stories($datetoget)
 
 {
 //query has returned no stories from yesterday (holiday, etc.)
 //keep subtracting on day from yesterday's date until there are stories
 found
 $datetoget=($datetoget-1);
 get_most_recent_stories($datetoget);
 }
 
 --
 Faye Keesic
 Computer Programmer Analyst/Web Page Design
 
 
 From: Rick Emery [EMAIL PROTECTED]
 Date: Wed, 2 Jan 2002 09:05:42 -0600
 To: [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Date problem with new year
 
 No bug, mate.
 
 Post your code so that we can help ya...
 
 -Original Message-
 From: Faye Keesic [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, January 02, 2002 8:56 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Date problem with new year
 
 
 I have a db site that always displays the most recent occurrence of news
 stories
 
 The last occurrence of stories was last year (2001-12-31) and up to the new
 year rolling over, I had no difficulty subtracting days, etc.
 
 Is there a bug in Mysql?  PHP that I don't know of..
 
 Please help.
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]