Re: [PHP-DB] Date problem
At 12:26 PM 1/21/2007, Denis L. Menezes wrote: Dear friends. I have a date field in mysql called event_end . I want to run a query to find all records where the event_and is greater than today's date. I have written the following code. It does not work. Please point out the mistake. $today = getdate(); $sql="select * from events where event_end>'.$today.' order by event_start Asc "; Thanks denis How is your date formatted in the database. Compare that to the format returned by getdate(), then consider using date('Y-m-d'). That's assuming your MySQL date is stored as -mm-dd. Nonetheless, this should set you on the right road. It would also have helped your diagnosis if you echoed your SQL statement. Cheers - Miles Thompson -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.410 / Virus Database: 268.17.3/642 - Release Date: 1/20/2007 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Date problem
Dear friends. I have a date field in mysql called event_end . I want to run a query to find all records where the event_and is greater than today's date. I have written the following code. It does not work. Please point out the mistake. $today = getdate(); $sql="select * from events where event_end>'.$today.' order by event_start Asc "; Thanks denis -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Date problem again ;-)
I suppose there is a " submit_time" field in your DB table, so you could: "SELECT * FROM `tablename` WHERE `submit_time`>=".lastdays(3) lastdays() is a function you could create using mktime(),time(), and date() On Tue, 22 Mar 2005 16:28:39 -0500, Chris Payne <[EMAIL PROTECTED]> wrote: > Hi there everyone, > > OK I'm using the following in my query to display entries in the LAST 3 > days: > > DATE_SUB(CURDATE(),INTERVAL 3 DAY) <= ListingDate > > But it doesn't seem to affect the results, the date format in my DB column > (ListingDate - datatype is Date) is 2000-00-00 as in year, month and date - > is THAT the problem? That it needs to be an actual timestamp? If that is > the case I'm not sure how to approach this because the data MUST be in the > above format as it comes from a central DB every night. All I need to do is > display the current date plus also the previous x amount of days in between. > > I'm using PHP 4 with MySQL 4.0.22 (Not the latest MySQL I know, sigh). > > > Chris > > -- Sincerely, Forest Liu(åäè) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Date problem again ;-)
Hi there everyone, OK I'm using the following in my query to display entries in the LAST 3 days: DATE_SUB(CURDATE(),INTERVAL 3 DAY) <= ListingDate But it doesn't seem to affect the results, the date format in my DB column (ListingDate - datatype is Date) is 2000-00-00 as in year, month and date - is THAT the problem? That it needs to be an actual timestamp? If that is the case I'm not sure how to approach this because the data MUST be in the above format as it comes from a central DB every night. All I need to do is display the current date plus also the previous x amount of days in between. I'm using PHP 4 with MySQL 4.0.22 (Not the latest MySQL I know, sigh). Chris
RE: [PHP-DB] Date problem: data is current as of yesterday
-Original Message- From: Karen Resplendo To: [EMAIL PROTECTED] Sent: 02/07/04 19:36 Subject: [PHP-DB] Date problem: data is current as of yesterday The database queries all the sources at night after everyone has gone home. That means the data was current as of yesterday. This little snippet below returns yesterday's date, except that the first day of the month returns "0" for the day. Now, I know why this is happening, but I can't find out how to fix it (in VBA or SQL Server I would just say, "date()-1": $today = getdate(); $month = $today['month'] ; $mday = $today['mday'] -1; $year = $today['year']; echo "Data is current as of $month $mday, $year"; -- The mktime() function is your friend for this kind of date arithmetic. For example, this is one possible way to do what you want: $yesterday = mktime(12, 0, 0, $today['mon'], $today['mday']-1, $today['year']); echo "Data is current as of ".date("F j, Y", $yesterday); (Note the use of time 12:00:00 to avoid daylight savings oddities!) The examples on the date() and mktime() manual pages may suggest other possibilities to you. Cheers! Mike - Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Date problem: data is current as of yesterday
accidentally replied only to karen. > The database queries all the sources at night after everyone has gone home. That means the data was current as of yesterday. This little snippet below returns yesterday's date, except that the first day of the month returns "0" for > the day. Now, I know why this is happening, but I can't find out how to fix it (in VBA or SQL Server I would just > say, "date()-1": > $today = getdate(); > $month = $today['month'] ; > $mday = $today['mday'] -1; > $year = $today['year']; > echo "Data is current as of $month $mday, $year"; you can do the same thing with php. I'd use a timestamp and subtract 86400 (24 hours of seconds) $yesterday_at_this_time = date("Y-m-d H:i:s", time() - 86400); hth Jeff - Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Date problem: data is current as of yesterday
Use strtotime() instead.. http://us2.php.net/manual/en/function.strtotime.php Regards, Neal Carmine Nine Systems Corporation -Original Message- From: Karen Resplendo [mailto:[EMAIL PROTECTED] Sent: Friday, July 02, 2004 12:36 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Date problem: data is current as of yesterday The database queries all the sources at night after everyone has gone home. That means the data was current as of yesterday. This little snippet below returns yesterday's date, except that the first day of the month returns "0" for the day. Now, I know why this is happening, but I can't find out how to fix it (in VBA or SQL Server I would just say, "date()-1": $today = getdate(); $month = $today['month'] ; $mday = $today['mday'] -1; $year = $today['year']; echo "Data is current as of $month $mday, $year"; - Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Date problem: data is current as of yesterday
The database queries all the sources at night after everyone has gone home. That means the data was current as of yesterday. This little snippet below returns yesterday's date, except that the first day of the month returns "0" for the day. Now, I know why this is happening, but I can't find out how to fix it (in VBA or SQL Server I would just say, "date()-1": $today = getdate(); $month = $today['month'] ; $mday = $today['mday'] -1; $year = $today['year']; echo "Data is current as of $month $mday, $year"; - Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage!
Re: [PHP-DB] date problem in MySQL DB
Brett King wrote: Hi Angelo Yes you will have to reformat and he is something that may help you. Hope it does function dateCheckMysql ($date) { list($dateDay, $dateMonth, $dateYear) = explode("/", $date); if ((is_numeric($dateDay)) && (is_numeric($dateMonth)) && (is_numeric($dateYear))) { if (!checkdate($dateMonth, $dateDay, $dateYear)) { return false; } else { return($dateYear."/".$dateMonth."/".$dateDay); } } else { return false; } } function dateCheckForm($date) { list($dateYear, $dateMonth, $dateDay) = explode("-", $date); if ((is_numeric($dateDay)) && (is_numeric($dateMonth)) && (is_numeric($dateYear))) { return($dateDay."/".$dateMonth."/".$dateYear); } else { return false; } } Many Thanks Brett Wow, that's lots of code. I'd recommend something simpler. Like: $mysqlDate = date('Y-m-d', strtotime($myDate)); $myDate = date('m/d/Y', strtotime($mysqlDate)); No checking involved, just one line of code. -- paperCrane -- Question Everything, Reject Nothing -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] date problem in MySQL DB
Hi Angelo Yes you will have to reformat and he is something that may help you. Hope it does function dateCheckMysql ($date) { list($dateDay, $dateMonth, $dateYear) = explode("/", $date); if ((is_numeric($dateDay)) && (is_numeric($dateMonth)) && (is_numeric($dateYear))) { if (!checkdate($dateMonth, $dateDay, $dateYear)) { return false; } else { return($dateYear."/".$dateMonth."/".$dateDay); } } else { return false; } } function dateCheckForm($date) { list($dateYear, $dateMonth, $dateDay) = explode("-", $date); if ((is_numeric($dateDay)) && (is_numeric($dateMonth)) && (is_numeric($dateYear))) { return($dateDay."/".$dateMonth."/".$dateYear); } else { return false; } } Many Thanks Brett -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] date problem in MySQL DB
From: "Angelo Zanetti" <[EMAIL PROTECTED]> > This might be slightly off topic but hopefully someone can help. > I have a field that is a varchar and I stored dates in it. But now I want to > change the type of the column to date, but I have a problem that the formats > differ: > > my format: mm/dd/ > mySQL format: -mm-dd > > So can I either: > a. change the format of the date format > > or > > b. do i have to write a function that changes my format to the mySQL before > changing the column type?? You need to do option (b). Since this is a PHP list, I'd recommend strtotime() and date() to do the formatting. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] date problem in MySQL DB
Hi guys This might be slightly off topic but hopefully someone can help. I have a field that is a varchar and I stored dates in it. But now I want to change the type of the column to date, but I have a problem that the formats differ: my format: mm/dd/ mySQL format: -mm-dd So can I either: a. change the format of the date format or b. do i have to write a function that changes my format to the mySQL before changing the column type?? TIA Angelo Zanetti Disclaimer This e-mail transmission contains confidential information, which is the property of the sender. The information in this e-mail or attachments thereto is intended for the attention and use only of the addressee. Should you have received this e-mail in error, please delete and destroy it and any attachments thereto immediately. Under no circumstances will the Cape Technikon or the sender of this e-mail be liable to any party for any direct, indirect, special or other consequential damages for any use of this e-mail. For the detailed e-mail disclaimer please refer to http://www.ctech.ac.za/polic or call +27 (0)21 460 3911 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Date problem
> // Do some number crunching here // > > $newnow = $now-$numweeks; > > echo $now; > > $converted_date = date("d-m-y",$now); > > echo "$converted_date"; You should be running your $convewrted_date on $newnow, not $now Gary Every Sr. UNIX Administrator Ingram Entertainment (615) 287-4876 "Pay It Forward" mailto:[EMAIL PROTECTED] http://accessingram.com > -Original Message- > From: Chris Payne [mailto:[EMAIL PROTECTED] > Sent: Monday, July 14, 2003 3:45 AM > To: php > Subject: [PHP-DB] Date problem > > > Hi there everyone, > > I use the below code to grab the current date, convert it to > a unix timestamp to do some bits then it's supposed to change > the date back with the new values (IE: current date - x > amount of seconds) but it's not doing it correctly, it's > probably DEAD obvious to everyone as my brain has probably > fried :-) But here's the code, when I convert it back to > d,m,Y it says it's 2004 which it shouldn't. > > Thanks > > Chris > > --- > > $secsinweek = 604800; > > $numweeks = $secsinweek * 7; > > $curdate = date("d-m-Y"); > > // Split the strings into day, month, year > list($cd, $cm, $cy) = split("-", $curdate); > > // Create unix time stamps for the start and end date > $now = mktime(0,0,0,$cd,$cm,$cy); > > // Do some number crunching here // > > $newnow = $now-$numweeks; > > echo $now; > > $converted_date = date("d-m-y",$now); > > echo "$converted_date"; >
[PHP-DB] Date problem
Hi there everyone, I use the below code to grab the current date, convert it to a unix timestamp to do some bits then it's supposed to change the date back with the new values (IE: current date - x amount of seconds) but it's not doing it correctly, it's probably DEAD obvious to everyone as my brain has probably fried :-) But here's the code, when I convert it back to d,m,Y it says it's 2004 which it shouldn't. Thanks Chris --- $secsinweek = 604800; $numweeks = $secsinweek * 7; $curdate = date("d-m-Y"); // Split the strings into day, month, year list($cd, $cm, $cy) = split("-", $curdate); // Create unix time stamps for the start and end date $now = mktime(0,0,0,$cd,$cm,$cy); // Do some number crunching here // $newnow = $now-$numweeks; echo $now; $converted_date = date("d-m-y",$now); echo "$converted_date";
Re: [PHP-DB] date problem
maybe you should try if($date!=="-00-00") {do something} "Dl Neil" <[EMAIL PROTECTED]> wrote in message 0df801c1cb3d$c947e420$c200a8c0@jrbrown">news:0df801c1cb3d$c947e420$c200a8c0@jrbrown... > Rehab, > > > i have an input field in a form that accept date called $date and in > databse i made it of type $date so its defualt is -00-00 > > > > the problem is when i say: > > if($date!="-00-00") > > {do something} > > > > he doesn't understand $date!="-00-00" > > > Please copy-paste the actual error message. > Also, what is the CREATE TABLE schema for the date field? > Recommend showing us a little more of the surrounding code. > Have you tried adding a debug ECHO $date immediately before the IF > statement, to be sure what you're dealing with? > > Please advise, > =dn > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] date problem
Hi there, I would like to count the users out of a mysql db who registered after a certain date. The column I have in the db is a char and I do not want to change this anymore. This is how a typical entry looks like: May 29, 2002 This is how I tryed it: // while '10...' is unix timestamp june 1, 02 SELECT COUNT(*) AS c FROM users_table WHERE UNIX_TIMESTAMP( user_regdate ) > '1022882400' Thanx for any help on that, andy query -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] date problem
Hi there, I would like to count the users out of a mysql db who registered after a certain date. The column I have in the db is a char and I do not want to change this anymore. This is how a typical entry looks like: May 29, 2002 This is how I tryed it: // while '10...' is unix timestamp june 1, 02 SELECT COUNT(*) AS c FROM users_table WHERE UNIX_TIMESTAMP( user_regdate ) > '1022882400' Thanx for any help on that, andy -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Date problem
> i get $postdate from my mysql database,the problem is that i want > to increase that date by 6 months?? > its stored in mysql as date field http://www.mysql.com/doc/D/a/Date_and_time_functions.html check DATE_ADD :) hth pa -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Date problem
i get $postdate from my mysql database,the problem is that i want to increase that date by 6 months?? its stored in mysql as date field - Express yourself with a super cool email address from BigMailBox.com. Hundreds of choices. It's free! http://www.bigmailbox.com - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] date problem
if( strcmp($date,"-00-00") ) { do something} -Original Message- From: its me [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 14, 2002 12:16 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] date problem i have an input field in a form that accept date called $date and in databse i made it of type $date so its defualt is -00-00 the problem is when i say: if($date!="-00-00") {do something} he doesn't understand $date!="-00-00" Rehab M.Shouman - Express yourself with a super cool email address from BigMailBox.com. Hundreds of choices. It's free! http://www.bigmailbox.com - -- 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 problem
Rehab, > i have an input field in a form that accept date called $date and in databse i made it of type $date so its defualt is -00-00 > > the problem is when i say: > if($date!="-00-00") > {do something} > > he doesn't understand $date!="-00-00" Please copy-paste the actual error message. Also, what is the CREATE TABLE schema for the date field? Recommend showing us a little more of the surrounding code. Have you tried adding a debug ECHO $date immediately before the IF statement, to be sure what you're dealing with? Please advise, =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] date problem
i have an input field in a form that accept date called $date and in databse i made it of type $date so its defualt is -00-00 the problem is when i say: if($date!="-00-00") {do something} he doesn't understand $date!="-00-00" Rehab M.Shouman - Express yourself with a super cool email address from BigMailBox.com. Hundreds of choices. It's free! http://www.bigmailbox.com - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Date problem with new year
This all seems like a waste of cpu cyles to me. Why don't you just write a query like this and be done with it: SELECT * FROM Table WHERE Date_Column = MAX(Date_Column) Fred Faye Keesic <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > 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]
Re: [PHP-DB] Date problem with new year
Hi, If you're unable/unwilling to modify your PHP installation, or just playing favorites with MySQL functions over PHP functions, an alternative to using the gregoriantojd() function is to use mysql's date functions to format the date as a julian date. (Check the mysql manual for detailed syntax - it's a nice suite of formatting options). Cheers, db [EMAIL PROTECTED] wrote: > Sorry for the delay... include --enable-calendar in the php compilation. > > On Wed, 2 Jan 2002, Faye Keesic wrote: > > > 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]] > > >>>
Re: [PHP-DB] Date problem with new year
Sorry for the delay... include --enable-calendar in the php compilation. On Wed, 2 Jan 2002, Faye Keesic wrote: > 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] > >
Re: [PHP-DB] Date problem with new year
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]
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]
Re: [PHP-DB] Date problem with new year
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
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]
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-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]