# Changing note/card id (e.g. creation time)

**URL:** <https://forums.ankiweb.net/t/changing-note-card-id-e-g-creation-time/7212>\
**Category:** Add-ons\
**Created:** [February 4, 2021, 8:52am UTC](https://forums.ankiweb.net/t/changing-note-card-id-e-g-creation-time/7212 "2021-02-04T08:52:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArthurMilchior](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/arthurmilchior/32/4684_2.png) [@ArthurMilchior](https://forums.ankiweb.net/u/ArthurMilchior)\
**Post date:** [February 4, 2021, 8:52am UTC](https://forums.ankiweb.net/t/changing-note-card-id-e-g-creation-time/7212/1 "2021-02-04T08:52:28Z")

</div>

Hi,

Is there any way to change creation time of a note, or create a new note with a specified creation time (e.g. id) ? The only thing I could think of would be making a direct request to the database, which is not really beautiful. I don’t know whether it would break anything to do so, I don’t know why on rust, the features does not allow to flush card when the id is not already in the database, whether it’s only a check feature, or whether it ensure that some logic is maintened.

This would be useful at least for the add-on copy card, which can’t copy creation date anymore. (Technically, it never copied it, since ids are unique. But a difference of a few milliseconds is more acceptable than a difference of days or years)

---

<div class="post-metadata">

**Author:** ![Evita](https://avatars.discourse-cdn.com/v4/letter/e/73ab20/32.png) [@Evita](https://forums.ankiweb.net/u/Evita)\
**Post date:** [February 4, 2021, 9:04am UTC](https://forums.ankiweb.net/t/changing-note-card-id-e-g-creation-time/7212/2 "2021-02-04T09:04:47Z")

</div>

There’s an add-on for changing the card creation date, it might be helpful: [Change Card Creation Times - AnkiWeb](https://ankiweb.net/shared/info/217650262)

---

<div class="post-metadata">

**Author:** ![dae](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/dae/32/65_2.png) [@dae](https://forums.ankiweb.net/u/dae)\
**Post date:** [February 4, 2021, 11:37am UTC](https://forums.ankiweb.net/t/changing-note-card-id-e-g-creation-time/7212/3 "2021-02-04T11:37:16Z")

</div>

Distinguishing between “add” and “update” is necessary to catch cards accidentally being added when the intention was to update them - which can happen if some code tries to flush a card object which has already been deleted on the DB end. This could have been done with separate functions rather than an id of 0, but using a zero id was the easiest way to integrate into the existing code at the time IIRC.

For now you can just use sql to replace the id after a new card is added - provided you do it before the user has a chance to review or sync, it should not cause problems.

---

<div class="post-metadata">

**Author:** ![Margoulin](https://avatars.discourse-cdn.com/v4/letter/m/c6cbf5/32.png) [@Margoulin](https://forums.ankiweb.net/u/Margoulin)\
**Post date:** [August 8, 2024, 9:55pm UTC](https://forums.ankiweb.net/t/changing-note-card-id-e-g-creation-time/7212/4 "2024-08-08T21:55:46Z")

</div>

Hello,  
Is there any new dedicated way to do this ? I’m trying to update my addon ([Transfer scheduling data from one card to another](https://ankiweb.net/shared/info/94685914)) which is broken seemingly since Anki 23.10. I used to do

```auto
mw.col.db.execute("update cards set id = ? where id = ?", cid1, cid2)

```

As suggested here but this is not undoable anymore without `checkpoint()`. So I wanted to use a collectionOp :

```auto
card2.id = something
mw.col.update_card(card2)

```

but it’s not working. Thanks for your help !

---

<div class="post-metadata">

**Author:** ![Shigeyuki](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/shigeyuki/32/23878_2.png) [@Shigeyuki](https://forums.ankiweb.net/u/Shigeyuki)\
**Post date:** [August 9, 2024, 12:37am UTC](https://forums.ankiweb.net/t/changing-note-card-id-e-g-creation-time/7212/5 "2024-08-09T00:37:26Z")

</div>

Hello! I wanted to use your add-on so I forked it, but I just updated Qt5 so I don’t know how to solve that problem.(I’m not good with databases.)  
This may have something to do with that.  
[Add-on porting notes for Anki 2.1.45 : Undo/Redo](https://forums.ankiweb.net/t/add-on-porting-notes-for-anki-2-1-45/11212#undoredo-4)

---

<div class="post-metadata">

**Author:** ![Margoulin](https://avatars.discourse-cdn.com/v4/letter/m/c6cbf5/32.png) [@Margoulin](https://forums.ankiweb.net/u/Margoulin)\
**Post date:** [August 9, 2024, 7:30am UTC](https://forums.ankiweb.net/t/changing-note-card-id-e-g-creation-time/7212/6 "2024-08-09T07:30:44Z")

</div>

Hello @Shigeyuki, Thanks for the quick update so that users could still use it ! I’m trying to find back the full features (undo which is critical, and stay focused on the same card after the transfer) but I struggle eheh  
I also read the [Add-on porting notes for Anki 2.1.45 : Undo/Redo](https://forums.ankiweb.net/t/add-on-porting-notes-for-anki-2-1-45/11212#undoredo-4) but could not find a solution

---

<div class="post-metadata">

**Author:** ![Margoulin](https://avatars.discourse-cdn.com/v4/letter/m/c6cbf5/32.png) [@Margoulin](https://forums.ankiweb.net/u/Margoulin)\
**Post date:** [December 14, 2024, 4:31pm UTC](https://forums.ankiweb.net/t/changing-note-card-id-e-g-creation-time/7212/7 "2024-12-14T16:31:10Z")

</div>

Hi there, I’m still looking for a solution to update card id with a collectionOp. Any help appreciated, thanks ! 🙂
