Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8

Thread: Date_Format

  1. #1
    New Coder
    Join Date
    May 2006
    Posts
    34
    Thanks
    2
    Thanked 1 Time in 1 Post

    Date_Format

    I am trying to reformat my mySQL dates into some thing like this: Sun, Jul 9th 2006 04:56:23 PM, using Date_Format(date, '%a, %b %D %Y %r'), but it's not working. I don't know why, any help would be appreciated.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Replace "date" with "Now()".

  • #3
    New Coder
    Join Date
    May 2006
    Posts
    34
    Thanks
    2
    Thanked 1 Time in 1 Post
    Its not for the current time date is the col in my database.

    Edit: This is the entire query:
    $query = "SELECT `title`, `author`, Date_Format(date, '%a, %b %D %Y %r'), `content` FROM `news home` where `home` like 'home' order by `date` asc";
    Last edited by Big-Pat; 07-15-2006 at 05:21 PM.

  • #4
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,096
    Thanks
    2
    Thanked 23 Times in 23 Posts
    Do you have a field called Date_Format or just date in your database? MySQL is probably going to have a problem with that. You need to rename those fields to something else.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #5
    New Coder
    Join Date
    May 2006
    Posts
    34
    Thanks
    2
    Thanked 1 Time in 1 Post
    It's just date, but I will try that now.

  • #6
    New Coder
    Join Date
    May 2006
    Posts
    34
    Thanks
    2
    Thanked 1 Time in 1 Post
    Well I figured it out, I guess it was putting it in a different variable so I added "as post" so I could use $row['post'] in my for loop. What is it by default? It wasn't "date" and that was my assumption.

  • #7
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Ah, yes, that'll bite you for sure.

    The default variable is literally the name of what you select, i.e.

    $row["Date_Format(Now(), '%a, %b %D %Y %r')"]

    Which, needless to say, would be unwieldy to work with

  • #8
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    If you are posting a question where you are using some application to display the output, please make sure to mention that in your question as well.

    that would give folks a clue as to what could be the problem and point you towards that.

    If it is strictly a mysql query you would have had no problems returning the result in your original post. It was the call to that column that gave you the problem.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •