Re: [PHP-DB] time without seconds

2003-06-18 Thread David Robley
In article 
[EMAIL PROTECTED], 
[EMAIL PROTECTED] says...
 In general, is it better to have MySQL select less using TIME_FORMAT than=20
 to have PHP crop the info?
 
 -Lisi

The general rule of thumb seems to be: if mysql can do it, use mysql else 
use php.

-- 
Quod subigo farinam

$email =~ s/oz$/au/o;


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



[PHP-DB] time without seconds

2003-06-17 Thread Lisi
If I have a time stored in MySQL, and I only need the hour and minutes 
without seconds:

1) Can I crop this in PHP after retrieving it?

2) Is there a way to store this without the seconds in MySQL?

Same goes for storing a date without the year. I could use a regular char 
field, but I want to be able to retrieve a row that corresponds to the 
current month and day, currently I am doing this with

$month = date(n);
$day = date(d);
$query = SELECT ... WHERE MONTH(date) = $month AND DAYOFMONTH = $day;
Is there a better way to do this without storing unnecessary data?

Thanks,

-Lisi

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


Re: [PHP-DB] time without seconds

2003-06-17 Thread Ignatius Reilly
Check the TIME_FORMAT(time,format) MySQL function.

Ignatius
_
- Original Message -
From: Lisi [EMAIL PROTECTED]
To: PHP-DB [EMAIL PROTECTED]
Sent: Tuesday, June 17, 2003 1:16 PM
Subject: [PHP-DB] time without seconds


 If I have a time stored in MySQL, and I only need the hour and minutes
 without seconds:

 1) Can I crop this in PHP after retrieving it?

 2) Is there a way to store this without the seconds in MySQL?

 Same goes for storing a date without the year. I could use a regular char
 field, but I want to be able to retrieve a row that corresponds to the
 current month and day, currently I am doing this with

 $month = date(n);
 $day = date(d);
 $query = SELECT ... WHERE MONTH(date) = $month AND DAYOFMONTH = $day;

 Is there a better way to do this without storing unnecessary data?

 Thanks,

 -Lisi


 --
 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] time without seconds

2003-06-17 Thread John W. Holmes
Lisi wrote:
If I have a time stored in MySQL, and I only need the hour and minutes 
without seconds:

1) Can I crop this in PHP after retrieving it?
Sure, just chop off the last : and what's after it if in HH:MM:SS 
format, or the last two numbers if in HHMMSS format.

2) Is there a way to store this without the seconds in MySQL?
Not really. You could use DATE_FORMAT or TIME_FORMAT to format the 
date/time without the seconds, though.

Same goes for storing a date without the year. I could use a regular 
char field, but I want to be able to retrieve a row that corresponds to 
the current month and day, currently I am doing this with

$month = date(n);
$day = date(d);
$query = SELECT ... WHERE MONTH(date) = $month AND DAYOFMONTH = $day;
Is there a better way to do this without storing unnecessary data?
I don't think there's any way to not store the year. Just ignore it like 
you're doing.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A 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] time without seconds

2003-06-17 Thread Lisi
In general, is it better to have MySQL select less using TIME_FORMAT than 
to have PHP crop the info?

-Lisi

At 09:50 PM 6/17/03 -0400, John W. Holmes wrote:
Lisi wrote:
If I have a time stored in MySQL, and I only need the hour and minutes 
without seconds:
1) Can I crop this in PHP after retrieving it?
Sure, just chop off the last : and what's after it if in HH:MM:SS format, 
or the last two numbers if in HHMMSS format.

2) Is there a way to store this without the seconds in MySQL?
Not really. You could use DATE_FORMAT or TIME_FORMAT to format the 
date/time without the seconds, though.

Same goes for storing a date without the year. I could use a regular char 
field, but I want to be able to retrieve a row that corresponds to the 
current month and day, currently I am doing this with
$month = date(n);
$day = date(d);
$query = SELECT ... WHERE MONTH(date) = $month AND DAYOFMONTH = $day;
Is there a better way to do this without storing unnecessary data?
I don't think there's any way to not store the year. Just ignore it like 
you're doing.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals ­ www.phparch.com






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