Bluehost.com Web Hosting $6.95

Changing date format

This is a discussion on Changing date format within the MySQL Database forums, part of the Database Forums category; Hi, I have a MySql database table USERS with about a 1000 records. I have a field called Date_joined where ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-30-2006
mohammed.naghman@gmail.com
 
Posts: n/a
Default Changing date format

Hi,

I have a MySql database table USERS with about a 1000 records.

I have a field called Date_joined where the date is stored in the
format like Fri Feb 24 10:03:46 PST 2006.

How can I convert this date format to 02/24/2006?

Is there any query that would convert this field for all the records?

Reply With Quote
  #2 (permalink)  
Old 10-31-2006
The|Godfather
 
Posts: n/a
Default Re: Changing date format

Hi,

Just check out the following link: ( self explanatory )
http://dev.mysql.com/doc/refman/5.1/...functions.html

Read about the 2 functions you need:

STR_TO_DATE(str,format)

AND

DATE_FORMAT()

They do the magic (for your case you need the first one only)
Hope it helps.

Cheers,
Dragomir Stanchev

-------------------------
mohammed.naghman@gmail.com wrote:
> Hi,
>
> I have a MySql database table USERS with about a 1000 records.
>
> I have a field called Date_joined where the date is stored in the
> format like Fri Feb 24 10:03:46 PST 2006.
>
> How can I convert this date format to 02/24/2006?
>
> Is there any query that would convert this field for all the records?


Reply With Quote
  #3 (permalink)  
Old 10-31-2006
strawberry
 
Posts: n/a
Default Re: Changing date format


The|Godfather wrote:
> Hi,
>
> Just check out the following link: ( self explanatory )
> http://dev.mysql.com/doc/refman/5.1/...functions.html
>
> Read about the 2 functions you need:
>
> STR_TO_DATE(str,format)
>
> AND
>
> DATE_FORMAT()
>
> They do the magic (for your case you need the first one only)
> Hope it helps.
>
> Cheers,
> Dragomir Stanchev
>
> -------------------------
> mohammed.naghman@gmail.com wrote:
> > Hi,
> >
> > I have a MySql database table USERS with about a 1000 records.
> >
> > I have a field called Date_joined where the date is stored in the
> > format like Fri Feb 24 10:03:46 PST 2006.
> >
> > How can I convert this date format to 02/24/2006?
> >
> > Is there any query that would convert this field for all the records?


Consider storing the date in the mysql datetime format (YYYY-MM-DD
HH:MM:SS) and then displaying it in whatever format you like when you
retrieve it.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 04:06 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0