Nodral Posted November 30, 2011 Share Posted November 30, 2011 Hi I am running a query which should only pull back the year from my DB table, however I am getting a list of null results My query is SELECT YEAR('Date') as year FROM courses and my data is ID EMPNO Coursename Date 1389 429 NFR Returns 2007-06-12 10:00:00 1390 429 Age Discrimination Conference Call 2006-09-13 14:00:00 1391 429 HOME Getting More Out Of Your Day 2007-09-07 09:30:00 1392 429 Pivotal Launch 2005-04-21 10:00:00 1393 429 Coaching for Improved Performance 2005-05-25 09:30:00 ANy ideas? I only need to return the date from this Date is set as a DateTime data type Quote Link to comment https://forums.phpfreaks.com/topic/252138-date-formatting/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 30, 2011 Share Posted November 30, 2011 The single-quotes around 'Date' make it a string, made up of the characters - D, a, t, and e. You don't put single-quotes around column (or table) names. Quote Link to comment https://forums.phpfreaks.com/topic/252138-date-formatting/#findComment-1292681 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.