Creation date

178 views
Skip to first unread message

Javier Peñas Fernández

unread,
Aug 19, 2023, 6:30:23 AM8/19/23
to mementodatabase
Hi. When I export a database to a CSV file, the creation date of each record is not included. Do you know how I could get it? Thank you so much.

Bill Crews

unread,
Aug 19, 2023, 9:34:56 AM8/19/23
to Javier Peñas Fernández, mementodatabase
I don't know how you're using the CSV file, but if you're importing it to Memento or probably anywhere else, the creation date of all imported entries become the date it was created during import, I believe, so yes, if you select the Info option on an imported entry, it will probably show the date of import.

To preserve it, I would create a Date or DateTime field for it, and set its default to the current date & time. If you never update it, that date & time will never change. If the risk that it could change is bothersome to you, you could, instead of using the default, set it with a CreatingTheEntry trigger, BeforeSavingTheEntry trigger with the following script in the trigger...

entry().set("Creation date", Date.now().getTime());

This script will run only when creating the entry.


On Sat, Aug 19, 2023 at 6:30 AM Javier Peñas Fernández <javie...@gmail.com> wrote:
Hi. When I export a database to a CSV file, the creation date of each record is not included. Do you know how I could get it? Thank you so much.

--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mementodatabase/b4106c5c-62ef-4a69-aa8c-6dd1aacb3ff0n%40googlegroups.com.

Er Mo

unread,
Aug 19, 2023, 10:56:42 AM8/19/23
to mementodatabase
Hallo
Das Ex - Importieren ist nur für die Daten gedacht . Die CSV Datei enthält keinerlei Daten die mit der Bibliothekstruktur zutuhn haben .
Wenn du das Datum haben wilst musst du , wie Bill schon beschrieb , vorgehen .

Hello
The ex - import is for the data only . The CSV file does not contain any data related to the library structure.
If you want the date you have to proceed as Bill already described.

Ernst

Javier Peñas Fernández

unread,
Aug 19, 2023, 2:15:03 PM8/19/23
to mementodatabase
Thank you very much, Bill.

When I include the script that you indicate as a trigger, I get the following error when creating an entry: “Org.mozilla.javascript.EcmaError: TypeError: Cannot find function getTime in object 1692465268638”.

In any case, what I would like to achieve is that in all the entries already entered in the database, a field is filled with the date of creation of each entry. My ultimate goal is to get a file to work in Excel, so that I can, for example, filter entries created between two dates.

Thanks again Bill.

Er Mo

unread,
Aug 19, 2023, 2:41:58 PM8/19/23
to mementodatabase
Hallo
Das Filtern ist auch in Memento möglich . Hast du ein Datumsfeld erstellt und den Feldnamen mit den Skript abgeklichen ?

Hello
Filtering is also possible in Memento. Did you create a date field and match the field name with the script?

Ernst

Javier Peñas Fernández

unread,
Aug 19, 2023, 2:56:01 PM8/19/23
to mementodatabase
Hello, Ernst.

In the library I have created a Date field called "CREATION" and the script is: entry().set("CREATION",Date.now().getTime());

Thanks, Ernst.

Bill Crews

unread,
Aug 19, 2023, 3:06:13 PM8/19/23
to Javier Peñas Fernández, mementodatabase
Yes, that's my error. Just use...

entry().set("Creation date", Date.now());

As for getting the entry's creation date into your field, try a library action with the following script...

let entries = lib().entries();
let count = 0;
for (x in entries) {
    let e = entries[x];
    if (e.field("Creation date") == null) {
        e.set("Creation date", e.creationTime);
        count += 1;
    }
}
message("Found " + count + " empty fields");

The message is displayed for only 3 seconds at the bottom of the screen on mobile devices, so watch for it.


Javier Peñas Fernández

unread,
Aug 20, 2023, 4:27:19 AM8/20/23
to mementodatabase
Thank you very much, Bill. It works perfectly.

Regards.

Reply all
Reply to author
Forward
0 new messages