Answers.Body: <p>Just in case anyone else comes across this problem in the future I actually managed to figure it out myself.</p>
  
  <p>I created kept the fieldtype as a DateTime field and grabbed the date/time and the extra value within the prepValueFromPost function then pushed the extra data into a custom table and post just the datetime to the craft_contents table.</p>
  
  <p>Then within the getInputHtml function I grabbed the extra data from the custom table to display along with the date/time.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-03T14:01:41.197Z
Answers.LastActivityDate: 2017-03-03T14:01:41.197Z
Answers.UserDisplayName: wizzer711
Body: <p>I wish to have a custom fieldtype which contains the standard datetime field abilities along with storing an extra piece of data. I have created a custom fieldtype for this with a mixed attributetype to store the data as JSON.</p>
  
  <p>However I am having problems when I try to query some of the data from the frontend.</p>
  
  <p>For example to pull out a specific piece of data I am currently doing:</p>
  
  <pre><code>variableName.date
  </code></pre>
  
  <p>This correctly pulls out the date I have stored. However when using this in the example:</p>
  
  <pre><code>craft.entries({ type: 'sectionName', customFieldtype.date: '&gt;=' ~ now|date(c) }).order('customFieldtype.date asc').first()
  </code></pre>
  
  <p>I get errors as when Craft converts this to SQL it's converting these to column names and customFieldtype.date doesn't exist.</p>
  
  <p>Is there any way around this bar having to re-create the built in craft entries calls in pure SQL?</p>
  
Tags: <datetime><custom-fieldtype>
Title: Using data within a mixed attribute type to query Craft entries dates
ThreadText: # Using data within a mixed attribute type to query Craft entries dates
  
  (Asked by: username_0 on 2017-03-01)
  
  I wish to have a custom fieldtype which contains the standard datetime field abilities along with storing an extra piece of data. I have created a custom fieldtype for this with a mixed attributetype to store the data as JSON.
  
  However I am having problems when I try to query some of the data from the frontend.
  
  For example to pull out a specific piece of data I am currently doing:
  
  ```
  variableName.date
  
  ```
  
  This correctly pulls out the date I have stored. However when using this in the example:
  
  ```
  craft.entries({ type: 'sectionName', customFieldtype.date: '>=' ~ now|date(c) }).order('customFieldtype.date asc').first()
  
  ```
  
  I get errors as when Craft converts this to SQL it's converting these to column names and customFieldtype.date doesn't exist.
  
  Is there any way around this bar having to re-create the built in craft entries calls in pure SQL?
  
  **Tags:** datetime, custom-fieldtype
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-03-03. Score: 2
  
  Just in case anyone else comes across this problem in the future I actually managed to figure it out myself.
  
  I created kept the fieldtype as a DateTime field and grabbed the date/time and the extra value within the prepValueFromPost function then pushed the extra data into a custom table and post just the datetime to the craft\_contents table.
  
  Then within the getInputHtml function I grabbed the extra data from the custom table to display along with the date/time.
  
  
  ---
  
  