Re: [PHP-DB] Date question
This works perfect, Bastien! Many thanks. Gerry On 3/13/06, Bastien Koert <[EMAIL PROTECTED]> wrote: > > select * from table where date_format(date_field, '%Y-%m') = '2006-02' > > > bastien > > > >From: "Gerry Danen" <[EMAIL PROTECTED]> > >To: php-db@lists.php.net > >CC: [EMAIL PROTECTED] > >Subject: [PHP-DB] Date question > >Date: Sun, 12 Mar 2006 20:44:13 -0700 > > > >While I am rebuilding my crashed laptop (the machine that had all my > >intelligence), I started thinking about a select statement I need. > > > >I have log info in a table and want to extract it on a monthly basis. The > >date field is in -mm-dd format. What's a good way to select those > dates > >that match 2006-02, for example. > > > >I apologize if the solution should be staring me in the face, but all my > >favorites and help files are toast, until I can restore some of them. >
RE: [PHP-DB] Date question
select * from table where date_format(date_field, '%Y-%m') = '2006-02' bastien From: "Gerry Danen" <[EMAIL PROTECTED]> To: php-db@lists.php.net CC: [EMAIL PROTECTED] Subject: [PHP-DB] Date question Date: Sun, 12 Mar 2006 20:44:13 -0700 While I am rebuilding my crashed laptop (the machine that had all my intelligence), I started thinking about a select statement I need. I have log info in a table and want to extract it on a monthly basis. The date field is in -mm-dd format. What's a good way to select those dates that match 2006-02, for example. I apologize if the solution should be staring me in the face, but all my favorites and help files are toast, until I can restore some of them. TIA. Gerry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Date question
Gerry Danen wrote: While I am rebuilding my crashed laptop (the machine that had all my intelligence), I started thinking about a select statement I need. I have log info in a table and want to extract it on a monthly basis. The date field is in -mm-dd format. What's a good way to select those dates that match 2006-02, for example. I apologize if the solution should be staring me in the face, but all my favorites and help files are toast, until I can restore some of them. Which database are you using? Mysql has this: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html Postgresql has: http://www.postgresql.org/docs/8.1/static/functions-datetime.html I'm sure others have the same sort of functionality. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Date question
For example, you have table `logs` with `datelog` field and you want to select dates that match 2006-02. You can try this select statement: SELECT * FROM `logs` WHERE MONTH(datelog)='02' and YEAR(datelog)='2006' Hope that helps. LJ Regalado
Re: [PHP-DB] Date Question
Bomgardner, Mark A wrote: I am having trouble converting a date from mm/dd/ to -mm-dd on a user form. I know there was post about this, but I keep getting an error message when I try to search the archives. I have looked at the manual, but I am not finding what I am looking for. echo date('Y-m-d',strtotime('09/24/2004')); -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Date Question
How are you trying to convert the date? bastien From: "Bomgardner, Mark A" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Subject: [PHP-DB] Date Question Date: Wed, 27 Oct 2004 11:17:16 -0500 I am having trouble converting a date from mm/dd/ to -mm-dd on a user form. I know there was post about this, but I keep getting an error message when I try to search the archives. I have looked at the manual, but I am not finding what I am looking for. Mark A. Bomgardner Technology Specialist KLETC -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Date Question
On Saturday 30 November 2002 12:30, Chris Payne wrote: > Hi there everyone, > > I've never really used the date functions beyond getting it to store the > current date in a db. > > I have a dilema in that I need to get all the days in the current month and > all the days in the next month (whatever the next month is depends on the > current month the script was ran)). Please be more specific. What are you doing with the days that you get? Are you putting them into an array? Or did you want to query a database for dates that lie within a certain range? If the latter then please say which database you're using. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Fortune finishes the great quotations, #12 Those who can, do. Those who can't, write the instructions. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Date Question
It would seem that on the page that you post your form to, you'll need to have a $date = date( "m.d.Y" ); to generate the actual date value.. That is if I understand correctly the date() function and the question. Later, Bob Weaver - Original Message - From: "Jennifer Downey" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, April 03, 2002 5:26 PM Subject: [PHP-DB] Date Question > Hi all, > > If I have a feild called 'date' and the type is date when a form is > submitted isn't it suppose to automatically enter the date or do I need to > somehow enter it through the form? > > The reason I ask is that I have another form with a date type and no > reference to it in the form and it is always entered. With this new form the > date is not entered into the db. > > Any ideas why? > > > TIA > Jennifer > > > > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.344 / Virus Database: 191 - Release Date: 4/2/2002 > > > > -- > 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 Question
Jennifer, assuming you are using MySQL, then I would imagine the field which is updating itself automatically is actually a TIMESTAMP type, rather than plain DATE (or perhaps DATESTAMP?) The *STAMP ones will update themselves I am pretty sure - but you might want to check this. HTH Beau // -Original Message- // From: Jennifer Downey [mailto:[EMAIL PROTECTED]] // Sent: Thursday, 4 April 2002 8:27 AM // To: [EMAIL PROTECTED] // Subject: [PHP-DB] Date Question // // // Hi all, // // If I have a feild called 'date' and the type is date when a form is // submitted isn't it suppose to automatically enter the date // or do I need to // somehow enter it through the form? // // The reason I ask is that I have another form with a date type and no // reference to it in the form and it is always entered. With // this new form the // date is not entered into the db. // // Any ideas why? // // // TIA // Jennifer // // // // // // --- // Outgoing mail is certified Virus Free. // Checked by AVG anti-virus system (http://www.grisoft.com). // Version: 6.0.344 / Virus Database: 191 - Release Date: 4/2/2002 // // // // -- // 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