Answers.Body: <p>One way to change the dateCreated value for an asset is to delete the asset and then re-upload it, setting the dateCreated value to the desired date when you do so. However, this will result in a new record being created for the asset in the database, and any references to the asset (such as from an Entry or a Matrix field) will be lost.</p>
  <p>Another option might be to write a custom plugin that provides a way for you to update the dateCreated value for an asset. You could use the saveAsset controller action as a starting point, and add a new field to the asset edit form where you can specify the new dateCreated value. You would then need to update the dateCreated value in the database using something like the following code:</p>
  <pre><code>Craft::$app-&gt;getDb()-&gt;createCommand()
      -&gt;update('{{%assets}}', ['dateCreated' =&gt; $newDateCreatedValue], ['id' =&gt; $assetId])
      -&gt;execute();
  </code></pre>
  <p>Keep in mind that you would need to be careful when updating the dateCreated value, as it could potentially cause issues if other parts of your site rely on the original dateCreated value.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-05T21:48:09.660Z
Answers.LastActivityDate: 2023-01-05T21:48:09.660Z
Answers.UserDisplayName: JBrew30
Answers.Body: <p>The <code>dateCreated</code> column you're referring to is more of a minimum internal audit trail that Craft uses when a new row is inserted into the database (along with <code>dateUpdated</code>).</p>
  <p>Is sounds like you want something that references the original time the asset was created, which would be stored in the images EXIF/metadata.  You could write a plugin that read that information: <a href="https://craftcms.stackexchange.com/a/8521/57">https://craftcms.stackexchange.com/a/8521/57</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-10T04:09:22.593Z
Answers.LastActivityDate: 2020-08-10T04:09:22.593Z
Answers.UserDisplayName: Brad Bell
Body: <p>I'm using graphql to pull in some assets/pdfs and ordering them by dateCreated, however the files go back a few years (i.e. files from 2019, files from 2018 etc.) but they weren't uploaded in the correct chronological order. Is there a way I can change the 'dateCreated' or 'Created at' date?  I changed the dateCreated column within the assets table of the database, but that didn't change anything within Craft or the graphql query.</p>
  <p>Any help is appreciated.</p>
  
Tags: <assets><database><datetime><graphql>
Title: How can I change the Date Created for Assets?
ThreadText: # How can I change the Date Created for Assets?
  
  (Asked by: username_0 on 2020-08-08)
  
  I'm using graphql to pull in some assets/pdfs and ordering them by dateCreated, however the files go back a few years (i.e. files from 2019, files from 2018 etc.) but they weren't uploaded in the correct chronological order. Is there a way I can change the 'dateCreated' or 'Created at' date? I changed the dateCreated column within the assets table of the database, but that didn't change anything within Craft or the graphql query.
  
  Any help is appreciated.
  
  **Tags:** assets, database, datetime, graphql
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2023-01-05. Score: 1
  
  One way to change the dateCreated value for an asset is to delete the asset and then re-upload it, setting the dateCreated value to the desired date when you do so. However, this will result in a new record being created for the asset in the database, and any references to the asset (such as from an Entry or a Matrix field) will be lost.
  
  Another option might be to write a custom plugin that provides a way for you to update the dateCreated value for an asset. You could use the saveAsset controller action as a starting point, and add a new field to the asset edit form where you can specify the new dateCreated value. You would then need to update the dateCreated value in the database using something like the following code:
  
  ```
  Craft::$app->getDb()->createCommand()
      ->update('{{%assets}}', ['dateCreated' => $newDateCreatedValue], ['id' => $assetId])
      ->execute();
  
  ```
  
  Keep in mind that you would need to be careful when updating the dateCreated value, as it could potentially cause issues if other parts of your site rely on the original dateCreated value.
  
  
  ---
  
  ### Answer by username_2 on 2020-08-10. Score: 0
  
  The `dateCreated` column you're referring to is more of a minimum internal audit trail that Craft uses when a new row is inserted into the database (along with `dateUpdated`).
  
  Is sounds like you want something that references the original time the asset was created, which would be stored in the images EXIF/metadata. You could write a plugin that read that information: <https://craftcms.stackexchange.com/a/8521/57>
  
  
  ---
  
  