Re: date issue
On 3 Feb 2003, at 13:58, Stefan Hinz, iConnect (Berlin wrote: You could use the DATE_FORMAT() function of MySQL for this: mysql SELECT DATE_FORMAT(NOW(),'%M'); +-+ | DATE_FORMAT(NOW(),'%M') | +-+ | February| +-+ You can't compare this with something like 'January', though, because 'January' is a string while the above result is a date. If your query string has 'month=January', this is a design problem, and you will have to use a bit of array magic to convert your string into a date for comparison. Someone slap me if there is an easy way _in MySQL_ to accomplish this. Slap! The DATE_FORMAT() function returns a string that can be compared just like any other string, so a query containing DATE_FORMAT(date_column, '%M') = 'January' should work as expected, as far as I can tell. But I agree with you that having month=January rather than month=1 is probably not the ideal design. -- Keith C. Ivey [EMAIL PROTECTED] Tobacco Documents Online http://tobaccodocuments.org Phone 202-667-6653 - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: date issue
Well, this query works, so it must be doable SELECT DATE_FORMAT(NOW(),'%M') AS TheMonth, IF(DATE_FORMAT(NOW(),'%M')='February','Yep','Nope') AS IFCheck FROM pickAnyTableAsLongAsItExists WHERE DATE_FORMAT(NOW(),'%M') = 'February' LIMIT 1; And provided the month is indeed February. ;) Not sure if you can do a range of months, though you could use the IN clause with the WHERE clause. - Original Message - From: Stefan Hinz, iConnect (Berlin) [EMAIL PROTECTED] To: Daniel Rossi [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, February 03, 2003 12:58 PM Subject: Re: date issue Daniel, (you posted this question twice, but I will only answer it once ;-) have a month string January from a get query string like so ?month=January , and i need to check a range of results within an endate so i need WHERE end_date $_GET['month'] , You could use the DATE_FORMAT() function of MySQL for this: mysql SELECT DATE_FORMAT(NOW(),'%M'); +-+ | DATE_FORMAT(NOW(),'%M') | +-+ | February| +-+ You can't compare this with something like 'January', though, because 'January' is a string while the above result is a date. If your query string has 'month=January', this is a design problem, and you will have to use a bit of array magic to convert your string into a date for comparison. Someone slap me if there is an easy way _in MySQL_ to accomplish this. Regards, -- Stefan Hinz [EMAIL PROTECTED] Geschäftsführer / CEO iConnect GmbH http://iConnect.de Heesestr. 6, 12169 Berlin (Germany) Tel: +49 30 7970948-0 Fax: +49 30 7970948-3 - Original Message - From: Daniel Rossi [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 03, 2003 1:41 AM Subject: date issue hi there i am having an issue formatting a date string back to mysql for a query, say i have a month string January from a get query string like so ?month=January , and i need to check a range of results within an endate so i need WHERE end_date $_GET['month'] , how can i format the month string back to mysql so it can understand it , let me know thanks - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: date issue
man this took a day to get to the list, it needs to check a range in particular month end_date or month start_date Kevin Smith [EMAIL PROTECTED] 02/04/03 08:55am Well, this query works, so it must be doable SELECT DATE_FORMAT(NOW(),'%M') AS TheMonth, IF(DATE_FORMAT(NOW(),'%M')='February','Yep','Nope') AS IFCheck FROM pickAnyTableAsLongAsItExists WHERE DATE_FORMAT(NOW(),'%M') = 'February' LIMIT 1; And provided the month is indeed February. ;) Not sure if you can do a range of months, though you could use the IN clause with the WHERE clause. - Original Message - From: Stefan Hinz, iConnect (Berlin) [EMAIL PROTECTED] To: Daniel Rossi [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, February 03, 2003 12:58 PM Subject: Re: date issue Daniel, (you posted this question twice, but I will only answer it once ;-) have a month string January from a get query string like so ?month=January , and i need to check a range of results within an endate so i need WHERE end_date $_GET['month'] , You could use the DATE_FORMAT() function of MySQL for this: mysql SELECT DATE_FORMAT(NOW(),'%M'); +-+ | DATE_FORMAT(NOW(),'%M') | +-+ | February| +-+ You can't compare this with something like 'January', though, because 'January' is a string while the above result is a date. If your query string has 'month=January', this is a design problem, and you will have to use a bit of array magic to convert your string into a date for comparison. Someone slap me if there is an easy way _in MySQL_ to accomplish this. Regards, -- Stefan Hinz [EMAIL PROTECTED] Geschäftsführer / CEO iConnect GmbH http://iConnect.de Heesestr. 6, 12169 Berlin (Germany) Tel: +49 30 7970948-0 Fax: +49 30 7970948-3 - Original Message - From: Daniel Rossi [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 03, 2003 1:41 AM Subject: date issue hi there i am having an issue formatting a date string back to mysql for a query, say i have a month string January from a get query string like so ?month=January , and i need to check a range of results within an endate so i need WHERE end_date $_GET['month'] , how can i format the month string back to mysql so it can understand it , let me know thanks - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: date issue
Stefan, You had it. SELECT columnName FROM tableName WHERE DATE_FORMAT(columnName, '%M') = 'January'; Regards, Victor Pendleton -Original Message- From: Stefan Hinz, iConnect (Berlin) [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 6:59 AM To: Daniel Rossi; [EMAIL PROTECTED] Subject: Re: date issue Daniel, (you posted this question twice, but I will only answer it once ;-) have a month string January from a get query string like so ?month=January , and i need to check a range of results within an endate so i need WHERE end_date $_GET['month'] , You could use the DATE_FORMAT() function of MySQL for this: mysql SELECT DATE_FORMAT(NOW(),'%M'); +-+ | DATE_FORMAT(NOW(),'%M') | +-+ | February| +-+ You can't compare this with something like 'January', though, because 'January' is a string while the above result is a date. If your query string has 'month=January', this is a design problem, and you will have to use a bit of array magic to convert your string into a date for comparison. Someone slap me if there is an easy way _in MySQL_ to accomplish this. Regards, -- Stefan Hinz [EMAIL PROTECTED] Geschäftsführer / CEO iConnect GmbH http://iConnect.de Heesestr. 6, 12169 Berlin (Germany) Tel: +49 30 7970948-0 Fax: +49 30 7970948-3 - Original Message - From: Daniel Rossi [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 03, 2003 1:41 AM Subject: date issue hi there i am having an issue formatting a date string back to mysql for a query, say i have a month string January from a get query string like so ?month=January , and i need to check a range of results within an endate so i need WHERE end_date $_GET['month'] , how can i format the month string back to mysql so it can understand it , let me know thanks - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: date issue
this is how i soughta got it working $formatted_month = date(Ym,strtotime(1 $month 2003)); $where = WHERE (DATE_FORMAT(e.start_date,\%Y%m\) = '$formatted_month' || DATE_FORMAT(e.end_date,\%Y%m\) = '$formatted_month' AND '$formatted_month' DATE_FORMAT(e.start_date,\%Y%m\)); as just the month could mean any year so have to add the year aswell Victor Pendleton [EMAIL PROTECTED] 02/04/03 09:23am Stefan, You had it. SELECT columnName FROM tableName WHERE DATE_FORMAT(columnName, '%M') = 'January'; Regards, Victor Pendleton -Original Message- From: Stefan Hinz, iConnect (Berlin) [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 6:59 AM To: Daniel Rossi; [EMAIL PROTECTED] Subject: Re: date issue Daniel, (you posted this question twice, but I will only answer it once ;-) have a month string January from a get query string like so ?month=January , and i need to check a range of results within an endate so i need WHERE end_date $_GET['month'] , You could use the DATE_FORMAT() function of MySQL for this: mysql SELECT DATE_FORMAT(NOW(),'%M'); +-+ | DATE_FORMAT(NOW(),'%M') | +-+ | February| +-+ You can't compare this with something like 'January', though, because 'January' is a string while the above result is a date. If your query string has 'month=January', this is a design problem, and you will have to use a bit of array magic to convert your string into a date for comparison. Someone slap me if there is an easy way _in MySQL_ to accomplish this. Regards, -- Stefan Hinz [EMAIL PROTECTED] Geschäftsführer / CEO iConnect GmbH http://iConnect.de Heesestr. 6, 12169 Berlin (Germany) Tel: +49 30 7970948-0 Fax: +49 30 7970948-3 - Original Message - From: Daniel Rossi [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 03, 2003 1:41 AM Subject: date issue hi there i am having an issue formatting a date string back to mysql for a query, say i have a month string January from a get query string like so ?month=January , and i need to check a range of results within an endate so i need WHERE end_date $_GET['month'] , how can i format the month string back to mysql so it can understand it , let me know thanks - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
date issue
hi there i am having an issue formatting a date string back to mysql for a query, say i have a month string January from a get query string like so ?month=January , and i need to check a range of results within an endate so i need WHERE end_date $_GET['month'] , how can i format the month string back to mysql so it can understand it , let me know thanks - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
date issue
sorry if you may get this twice, my work is persistant to not give me newsgroup access and their email server is shitty and slow , i think being on novell heh anyway here is the message. hi there i am having an issue formatting a date string back to mysql for a query, say i have a month string January from a get query string like so ?month=January , and i need to check a range of results within an endate so i need WHERE end_date $_GET['month'] , how can i format the month string back to mysql so it can understand it , let me know thanks - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: date issue
Daniel, (you posted this question twice, but I will only answer it once ;-) have a month string January from a get query string like so ?month=January , and i need to check a range of results within an endate so i need WHERE end_date $_GET['month'] , You could use the DATE_FORMAT() function of MySQL for this: mysql SELECT DATE_FORMAT(NOW(),'%M'); +-+ | DATE_FORMAT(NOW(),'%M') | +-+ | February| +-+ You can't compare this with something like 'January', though, because 'January' is a string while the above result is a date. If your query string has 'month=January', this is a design problem, and you will have to use a bit of array magic to convert your string into a date for comparison. Someone slap me if there is an easy way _in MySQL_ to accomplish this. Regards, -- Stefan Hinz [EMAIL PROTECTED] Geschäftsführer / CEO iConnect GmbH http://iConnect.de Heesestr. 6, 12169 Berlin (Germany) Tel: +49 30 7970948-0 Fax: +49 30 7970948-3 - Original Message - From: Daniel Rossi [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 03, 2003 1:41 AM Subject: date issue hi there i am having an issue formatting a date string back to mysql for a query, say i have a month string January from a get query string like so ?month=January , and i need to check a range of results within an endate so i need WHERE end_date $_GET['month'] , how can i format the month string back to mysql so it can understand it , let me know thanks - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php