I am trying this query:
SELECT ARTICLE_NO, USERNAME, ACCESSSTARTS, ARTICLE_NAME, date_format( ACCESSSTARTS, '%d %m %Y' ) AS shortDate FROM AUCTIONS WHERE upper( ARTICLE_NAME ) LIKE '%hardy%' LIMIT 0 , 10;
Which works fine, but shortDate is null, and I am unsure why.
The contents of the database is like so:
ARTICLE_NO USERNAME ACCESSSTARTS ARTICLE_NAME shortDate 110313660559 banger-wear 17.11.2008 13:24:56 acolshirt NULL
edit: The accessstarts field is not a datetime field but a varchar. I am unsure of what to do. Should I simply strip everything after the first space in ACCESSSTARTS to display only the date?
Or would it be better to convert the column to a datetime field, and if so, how would I specify that it should be in %D.%M.%Y format instead of the default, which apprantly starts with %Y
The formatting of ACCESSSTARTS looks like the date you have there is a varchar, but DATE_FORMAT expects a DATE or DATETIME value.
YOu could try using STR_TO_DATE to turn that string into a date value first, e.g.