[PHP-DB] Date_Format Question

2001-08-29 Thread Jeff Oien

I have a date like this in date format in MySQL
2001-08-29

and I want it to say
August 29, 2001

I tried this and it didn't work. 
select date_format('creation_date', '%b %D, %Y') from Chart_Users;

Could you tell me what I'm doing wrong or how I should do this? Thanks.
Jeff Oien

-- 
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_Format Question

2001-08-29 Thread boclair


- Original Message -
From: Jeff Oien <[EMAIL PROTECTED]>
To: PHP-DB <[EMAIL PROTECTED]>
Sent: Thursday, August 30, 2001 11:07 AM
Subject: [PHP-DB] Date_Format Question


> I have a date like this in date format in MySQL
> 2001-08-29
>
> and I want it to say
> August 29, 2001
>
> I tried this and it didn't work.
> select date_format('creation_date', '%b %D, %Y') from Chart_Users;

Perhaps

$result= "SELECT date_format(creation_date,'%b%D,%y') AS created  FROM
db.Chart_Users";

Then from the array $myrow['created']   instead of
$myrow['creation_date']

Tim Morris


-- 
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_Format Question

2001-08-29 Thread Jeff Oien

Isn't that what I tried?
Jeff Oien

> Although it might be better to format the date in php, don't forget you can
> also do date formating in the select string.  The date format functions for
> mySQL can me found here:
> 
> http://www.mysql.com/doc/D/a/Date_and_time_functions.html
> 
> Hope this helps,
> 
> 
> 
> -Original Message-
> From: Jeff Oien [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 29, 2001 8:07 PM
> To: PHP-DB
> Subject: [PHP-DB] Date_Format Question
> 
> 
> I have a date like this in date format in MySQL
> 2001-08-29
> 
> and I want it to say
> August 29, 2001
> 
> I tried this and it didn't work.
> select date_format('creation_date', '%b %D, %Y') from Chart_Users;
> 
> Could you tell me what I'm doing wrong or how I should do this? Thanks.
> Jeff Oien
> 
> --
> 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_Format Question

2001-08-29 Thread boclair


- Original Message -
From: boclair <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; PHP-DB <[EMAIL PROTECTED]>
Sent: Thursday, August 30, 2001 1:09 PM
Subject: Re: [PHP-DB] Date_Format Question


>
> - Original Message -
> From: Jeff Oien <[EMAIL PROTECTED]>
> To: PHP-DB <[EMAIL PROTECTED]>
> Sent: Thursday, August 30, 2001 11:07 AM
> Subject: [PHP-DB] Date_Format Question
>
>
> > I have a date like this in date format in MySQL
> > 2001-08-29
> >
> > and I want it to say
> > August 29, 2001
> >
> > I tried this and it didn't work.
> > select date_format('creation_date', '%b %D, %Y') from Chart_Users;
>
> Perhaps
>
> $result= "SELECT date_format(creation_date,'%b%D,%y') AS created
FROM
> db.Chart_Users";
>
> Then from the array $myrow['created']   instead of
> $myrow['creation_date']


The formatting you need is %M %d, %Y.  Careless of me.

Tim Morris


-- 
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_Format Question

2001-08-30 Thread Jeff Oien

Thanks for the help Christopher and boclair. I think my problem was
putting single quotes around the field name within the parenthesis:
select date_format('creation_date', '%b %D, %Y') from Chart_Users;

This works:
select date_format(creation_date, '%M %D, %Y') from Chart_Users;
or
select date_format(creation_date, '%M %D, %Y') as creation from Chart_Users;
Jeff Oien

> Jeff,
> 
> mysql> select now();
> +-+
> | now()   |
> +-+
> | 2001-08-29 21:21:50 |
> +-+
> 1 row in set (0.00 sec)
> 
> mysql> SELECT DATE_FORMAT(NOW(), '%b %D, %Y') AS 'Formatted Current Time';
> ++
> | Formatted Current Time |
> ++
> | Aug 29th, 2001 |
> ++
> 1 row in set (0.00 sec)
> 
> mysql> SELECT DATE_FORMAT(NOW(), '%M %d, %Y') 'Formatted Current Time';
> ++
> | Formatted Current Time |
> ++
> | August 29, 2001|
> ++
> 1 row in set (0.00 sec)
> 
> OR. [this ex: assumes you have the connection string established]
> 
> $strSQL = "SELECT DATE_FORMAT(NOW(), '%M %d, %Y') 'Formatted Current Time'";
> $results = mysql_query($strSQL, $db) or die("Cannot execute $strSQL");
> 
> list($formattedDate) = mysql_fetch_array($results);
> 
> and you're done!
> 
> HTH,
> 
> Christopher Oson
> 
> -Original Message-
> From: Jeff Oien [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 29, 2001 8:29 PM
> To: PHP-DB
> Subject: RE: [PHP-DB] Date_Format Question
> 
> 
> Isn't that what I tried?
> Jeff Oien
> 
> > Although it might be better to format the date in php, don't forget you
> can
> > also do date formating in the select string.  The date format functions
> for
> > mySQL can me found here:
> >
> > http://www.mysql.com/doc/D/a/Date_and_time_functions.html
> >
> > Hope this helps,
> >
> >
> >
> > -Original Message-
> > From: Jeff Oien [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, August 29, 2001 8:07 PM
> > To: PHP-DB
> > Subject: [PHP-DB] Date_Format Question
> >
> >
> > I have a date like this in date format in MySQL
> > 2001-08-29
> >
> > and I want it to say
> > August 29, 2001
> >
> > I tried this and it didn't work.
> > select date_format('creation_date', '%b %D, %Y') from Chart_Users;
> >
> > Could you tell me what I'm doing wrong or how I should do this? Thanks.
> > Jeff Oien
> >
> > --
> > 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]