We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Date query problem

Development and Programming

JerryDi's avatar
JerryDi
29 posts
15 years ago
JerryDi's avatar JerryDi

I am struggling to get this query to run I have a custom date field and want to select those entries that are for a specific year ie 2010:

{exp:query sql="
SELECT field_id_14 as Comp_date, field_id_15 as Competition, field_id_16 as Winner,  SUBSTRING(field_id_17, 13) as Image, 
field_id_18 as Caption, field_id_19 as Section
FROM exp_channel_data WHERE channel_id = '37' AND DATE_FORMAT(field_id_14, '%y') = '2010' AND field_id_19='Gents Golf'
ORDER BY field_id_14 ASC"}

However the above query returns no results even though I know I have 35 records that match; I know the problem is with the DATE_FORMAT(field_id_14, ‘%y’) = ‘2010’ bit Any ideas ? thanks PS I am running 2.1.1 and PHP 5.2.12

       
JerryDi's avatar
JerryDi
29 posts
15 years ago
JerryDi's avatar JerryDi

I have fixed this by using the FROM_UNIXTIME function instead

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.