SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL date function

    Hi,

    I'm having problems with the DATE_FORMAT function in MySQL. I have a date field in a table called tblArticles. I want to format it like: '1st Jan 2002'

    I think this is '%D %b %Y'. But when I execute the quesry I get a value of NULL! what is going on? Also is there a way of naming the result of the function for example aclling it fdate or summit. Thanks.

    See query below:

    Code:
    SELECT DATE_FORMAT('date', '%D %b %Y'), tblArticles.* FROM tblArticles, tblAType WHERE tblArticles.atid = tblAType.atid AND type != 'nw' AND type != 'fa' ORDER BY date DESC
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk

  2. #2
    SitePoint Enthusiast Grubilo's Avatar
    Join Date
    Oct 2002
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is an error in your code.
    You try to format the string 'date'.
    Try to specify field name without the quotes.
    just date or full name: table.field

    so:
    DATE_FORMAT(table.field, '%D %b %Y')
    good luck
    Web tutorials
    http://webclass.ru

  3. #3
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, That's mmuch better
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk


Bookmarks

Posting Permissions

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