SQL querry to get date and time of creation of a document

Hello I am trying to create properties field in a note.

I would like to get a row with the date and time of creation of the document
And in a second field I would like to do the same to get the update date and time.

Something like that

Properties

created: 2024-07-24 20h21
updated: 2024-07-24 20h36

Thanks for your help

    Welcome to here!

    Here we can learn from each other how to use SiYuan, give feedback and suggestions, and build SiYuan together.

    Signup About
    Please input reply content ...
    • laguill
      Author

      Hi,
      Thanks for your reply.
      Indeed I would like a query in the document that refresh itself automaticaly.
      Can I get the document id only with a template function or is the there variable I can use in the query ?

      Where can I get the document id ?

      1 Reply
    • MiscReply
    • laguill
      Author

      @Wetoria I tried also by using the sql command you provided but nothing is displaying I only have error 'Search content block does not exist'
      here is what I have in my template

      {{ SELECT created, updated from blocks where id = '.action{.id}';}}
      

      I tried something else with by creating a database with the properties key with the document and then 2 columns with created time and updated time
      But I could not find a way do to do it in a template
      Any Idea ?

      
      
      1 Operate
      laguill updated this reply at 2024-08-04 01:11:30
    • Wetoria 1

      Can you describe clearly where are you create in?

      If you want query creation and updated of a document, just use:

      select created, updated from blocks where id = 'your doc id';
      

      but this way cannot use in embed block, there are some reason.


      If you wanna insert the created and updated time into a doc.

      You can use the Template functio.

      There is a guide about it. SiYuan Template Function Guide for Newcomers: Template Syntax + Functions + Markdown Block Syntax .

      Use above sql in your template and used it by slash(/) menu.


      There are some other way to show both time in doc, but I dont know what result is you want.

      Plz give me more info.

      1 Reply
      1 Operate
      Wetoria updated this reply at 2024-07-26 16:22:40
    • Wetoria

      If i understand correctly, your mean is like to insert updated time in a doc automaticaly.

      If im correct, I advise you to use js embed block. something like use js in embed block.

      The template can not refresh at each time, when you insert a template, what you get is fixed with current time.

      Maybe @frostime can give you some js embed block infos.

      1 Reply