Jump to content

Data Format


barney0o0

Recommended Posts

Sorry, i know its been discussed on numerous occasions in the forums, but my head hurts for the simpliest of things.....

How do i change the code below to change the format from 2002-12-27 (database format) to 27 December 2002(pulled down display format)?

SELECT eventTITLE, eventDATE
FROM events
ORDER BY eventDATE ASC


...or would it be more efficant to change the format in php prior to pulling down the results?

Thanks in advance
Link to comment
Share on other sites

[!--quoteo(post=353184:date=Mar 9 2006, 08:47 AM:name=barney0o0)--][div class=\'quotetop\']QUOTE(barney0o0 @ Mar 9 2006, 08:47 AM) [snapback]353184[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Sorry, i know its been discussed on numerous occasions in the forums, but my head hurts for the simpliest of things.....

How do i change the code below to change the format from 2002-12-27 (database format) to 27 December 2002(pulled down display format)?

SELECT eventTITLE, eventDATE
FROM events
ORDER BY eventDATE ASC
...or would it be more efficant to change the format in php prior to pulling down the results?

Thanks in advance
[/quote]

I prefer to manipulate my date formats with PHP.

[code]
$query = mysql_query("SELECT eventTITLE, eventDATE FROM events ORDER BY eventDATE ASC");
if ($row = mysql_fetch_assoc($query))
{
   do
   {
      $date = date("d/m/Y", strtotime($row["eventDATE"]));
   }
   while ($row = mysql_fetch_assoc($query));
}

[/code]
Link to comment
Share on other sites

Cheers lessthan for your response....I had i play with your sugesstion, but as im using dreamweavers behaviours to display the pulled down data i got in a bit of a mess....

Ive now played and searched around and come up with:

SELECT DATE_FORMAT(eventdate2, '%D/%M/%Y') AS eventdate2, eventTITLE,paratext
FROM events
ORDER BY eventdate2

that produces

7th/February/2006
Music night2
Intro text

Is there a way to remove the forward slashes and replace with a space?

many thanks
Link to comment
Share on other sites

[!--quoteo(post=353290:date=Mar 9 2006, 11:06 AM:name=barney0o0)--][div class=\'quotetop\']QUOTE(barney0o0 @ Mar 9 2006, 11:06 AM) [snapback]353290[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Is there a way to remove the forward slashes and replace with a space?

many thanks
[/quote]

sure, just adjust your DATE_FORMAT function:
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] DATE_FORMAT(eventdate2, [color=red]'%D %M %Y'[/color]) [color=green]AS[/color] eventdate2, eventTITLE,paratext
[color=green]FROM[/color] [color=orange]events[/color] [color=green]ORDER BY[/color] eventdate2
[!--sql2--][/div][!--sql3--]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.