Making automatic updated date and time field in QGIS? The 2019 Stack Overflow Developer Survey...

What did it mean to "align" a radio?

How to manage monthly salary

Resizing object distorts it (Illustrator CC 2018)

For what reasons would an animal species NOT cross a *horizontal* land bridge?

Am I thawing this London Broil safely?

The difference between dialogue marks

Why not take a picture of a closer black hole?

Aging parents with no investments

Lightning Grid - Columns and Rows?

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

Is "plugging out" electronic devices an American expression?

Are there incongruent pythagorean triangles with the same perimeter and same area?

Right tool to dig six foot holes?

Did 3000BC Egyptians use meteoric iron weapons?

Where to refill my bottle in India?

Earliest use of the term "Galois extension"?

What does ひと匙 mean in this manga and has it been used colloquially?

Loose spokes after only a few rides

Falsification in Math vs Science

Are spiders unable to hurt humans, especially very small spiders?

Why isn't airport relocation done gradually?

Time travel alters history but people keep saying nothing's changed

How technical should a Scrum Master be to effectively remove impediments?

Why can Shazam fly?



Making automatic updated date and time field in QGIS?



The 2019 Stack Overflow Developer Survey Results Are InIs it possible to add the time of editing to the table of a shapefile?How to create in QGIS shapefile a field that automatically returns the current dateWhat to do to keep Python code permanent in QGIS 2.14.2?Making automatic updated date and time field in QGISHow to set NULL as default value for a date field in QGIS 2.4?Calculate Date field in ArcPyHow to update a DATE field when moving PostGIS geometry in QGIS?QGIS Server when builds the UPDATE query to postgis sets date field ='' instead of =null which raises an error in the DBQGIS date fields widget - unable to select todays date?Using Map Tips and Ruled Expression in QGIS?Time Manager date format without timeDisplaying time in the Date FieldIs it possible to add the time of editing to the table of a shapefile?Making automatic updated date and time field in QGIS





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







7















I want to make a date and time updated field as I edit an attribute field in this format yyyy-mm-dd 00:00:00 (= 2016-05-08 11:04:00) - my local date/time. The data is in a QGIS 2.14 shapefile and Vector lines as screenshot bellow.



When a feature as NULL in the 'name' field, I want to enter a name for the road and the 'mod' field must receive de modified date/time like '2016-05-08 15:16:00'.



I already tried some options and failed.
I need help to start from beginning.




  1. I create a new field, date/time type, but stays with NULL value after I edited, in the "name" field, or the feature it self.

  2. I used too, the expression now(), but stays with NULL value after I edited.


Note: the date seen there, 2016-04-14 is the first value created with "Field Calculator".



enter image description here



I am using QGIS 2.14.










share|improve this question

























  • Please edit your question to specify the data format and the versions of software in use. You should also specify the datatype of the target column (since date fields don't have formats)

    – Vince
    May 7 '16 at 13:17













  • Please edit the question to contain the requested information. You should detail what you have tried, and exactly how it failed. This will help allow our volunteers to understand what you are trying to achieve. As it stands, there isn't enough information to more than guess at a solution -- I'm imagining an autopopulate column in DB2 isn't going to meet your needs.

    – Vince
    May 7 '16 at 16:41











  • Sounds to me if you would like to store the timestamp of the last edit/update of a feature in an attribute, did I get you right? Something like what ESRI calls 'editor tracking'?

    – Jochen Schwarze
    May 7 '16 at 17:21






  • 2





    so what kind of data provider are you using (shape, postgis, ...) and by the way: is the 3-digit month a typing error or do you need something like 2016-may-08? perhaps catching the ´beforeCommitChanges´ signal of a ´QgsVectorLayer´ or an ´UPDATE´ trigger in postgesql might be successful.

    – Jochen Schwarze
    May 8 '16 at 9:19






  • 1





    Shapefile is a miserable data format for timestamps, since dBase only supports day resolution (it doesn't really support NULLs either). You need to use a character column for this information (which would then need to be parsed for any further use)

    – Vince
    May 8 '16 at 15:10


















7















I want to make a date and time updated field as I edit an attribute field in this format yyyy-mm-dd 00:00:00 (= 2016-05-08 11:04:00) - my local date/time. The data is in a QGIS 2.14 shapefile and Vector lines as screenshot bellow.



When a feature as NULL in the 'name' field, I want to enter a name for the road and the 'mod' field must receive de modified date/time like '2016-05-08 15:16:00'.



I already tried some options and failed.
I need help to start from beginning.




  1. I create a new field, date/time type, but stays with NULL value after I edited, in the "name" field, or the feature it self.

  2. I used too, the expression now(), but stays with NULL value after I edited.


Note: the date seen there, 2016-04-14 is the first value created with "Field Calculator".



enter image description here



I am using QGIS 2.14.










share|improve this question

























  • Please edit your question to specify the data format and the versions of software in use. You should also specify the datatype of the target column (since date fields don't have formats)

    – Vince
    May 7 '16 at 13:17













  • Please edit the question to contain the requested information. You should detail what you have tried, and exactly how it failed. This will help allow our volunteers to understand what you are trying to achieve. As it stands, there isn't enough information to more than guess at a solution -- I'm imagining an autopopulate column in DB2 isn't going to meet your needs.

    – Vince
    May 7 '16 at 16:41











  • Sounds to me if you would like to store the timestamp of the last edit/update of a feature in an attribute, did I get you right? Something like what ESRI calls 'editor tracking'?

    – Jochen Schwarze
    May 7 '16 at 17:21






  • 2





    so what kind of data provider are you using (shape, postgis, ...) and by the way: is the 3-digit month a typing error or do you need something like 2016-may-08? perhaps catching the ´beforeCommitChanges´ signal of a ´QgsVectorLayer´ or an ´UPDATE´ trigger in postgesql might be successful.

    – Jochen Schwarze
    May 8 '16 at 9:19






  • 1





    Shapefile is a miserable data format for timestamps, since dBase only supports day resolution (it doesn't really support NULLs either). You need to use a character column for this information (which would then need to be parsed for any further use)

    – Vince
    May 8 '16 at 15:10














7












7








7


1






I want to make a date and time updated field as I edit an attribute field in this format yyyy-mm-dd 00:00:00 (= 2016-05-08 11:04:00) - my local date/time. The data is in a QGIS 2.14 shapefile and Vector lines as screenshot bellow.



When a feature as NULL in the 'name' field, I want to enter a name for the road and the 'mod' field must receive de modified date/time like '2016-05-08 15:16:00'.



I already tried some options and failed.
I need help to start from beginning.




  1. I create a new field, date/time type, but stays with NULL value after I edited, in the "name" field, or the feature it self.

  2. I used too, the expression now(), but stays with NULL value after I edited.


Note: the date seen there, 2016-04-14 is the first value created with "Field Calculator".



enter image description here



I am using QGIS 2.14.










share|improve this question
















I want to make a date and time updated field as I edit an attribute field in this format yyyy-mm-dd 00:00:00 (= 2016-05-08 11:04:00) - my local date/time. The data is in a QGIS 2.14 shapefile and Vector lines as screenshot bellow.



When a feature as NULL in the 'name' field, I want to enter a name for the road and the 'mod' field must receive de modified date/time like '2016-05-08 15:16:00'.



I already tried some options and failed.
I need help to start from beginning.




  1. I create a new field, date/time type, but stays with NULL value after I edited, in the "name" field, or the feature it self.

  2. I used too, the expression now(), but stays with NULL value after I edited.


Note: the date seen there, 2016-04-14 is the first value created with "Field Calculator".



enter image description here



I am using QGIS 2.14.







qgis field-calculator update date datetime






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 14 '17 at 7:38









nmtoken

8,10042866




8,10042866










asked May 7 '16 at 10:51









Carlos PiresCarlos Pires

595318




595318













  • Please edit your question to specify the data format and the versions of software in use. You should also specify the datatype of the target column (since date fields don't have formats)

    – Vince
    May 7 '16 at 13:17













  • Please edit the question to contain the requested information. You should detail what you have tried, and exactly how it failed. This will help allow our volunteers to understand what you are trying to achieve. As it stands, there isn't enough information to more than guess at a solution -- I'm imagining an autopopulate column in DB2 isn't going to meet your needs.

    – Vince
    May 7 '16 at 16:41











  • Sounds to me if you would like to store the timestamp of the last edit/update of a feature in an attribute, did I get you right? Something like what ESRI calls 'editor tracking'?

    – Jochen Schwarze
    May 7 '16 at 17:21






  • 2





    so what kind of data provider are you using (shape, postgis, ...) and by the way: is the 3-digit month a typing error or do you need something like 2016-may-08? perhaps catching the ´beforeCommitChanges´ signal of a ´QgsVectorLayer´ or an ´UPDATE´ trigger in postgesql might be successful.

    – Jochen Schwarze
    May 8 '16 at 9:19






  • 1





    Shapefile is a miserable data format for timestamps, since dBase only supports day resolution (it doesn't really support NULLs either). You need to use a character column for this information (which would then need to be parsed for any further use)

    – Vince
    May 8 '16 at 15:10



















  • Please edit your question to specify the data format and the versions of software in use. You should also specify the datatype of the target column (since date fields don't have formats)

    – Vince
    May 7 '16 at 13:17













  • Please edit the question to contain the requested information. You should detail what you have tried, and exactly how it failed. This will help allow our volunteers to understand what you are trying to achieve. As it stands, there isn't enough information to more than guess at a solution -- I'm imagining an autopopulate column in DB2 isn't going to meet your needs.

    – Vince
    May 7 '16 at 16:41











  • Sounds to me if you would like to store the timestamp of the last edit/update of a feature in an attribute, did I get you right? Something like what ESRI calls 'editor tracking'?

    – Jochen Schwarze
    May 7 '16 at 17:21






  • 2





    so what kind of data provider are you using (shape, postgis, ...) and by the way: is the 3-digit month a typing error or do you need something like 2016-may-08? perhaps catching the ´beforeCommitChanges´ signal of a ´QgsVectorLayer´ or an ´UPDATE´ trigger in postgesql might be successful.

    – Jochen Schwarze
    May 8 '16 at 9:19






  • 1





    Shapefile is a miserable data format for timestamps, since dBase only supports day resolution (it doesn't really support NULLs either). You need to use a character column for this information (which would then need to be parsed for any further use)

    – Vince
    May 8 '16 at 15:10

















Please edit your question to specify the data format and the versions of software in use. You should also specify the datatype of the target column (since date fields don't have formats)

– Vince
May 7 '16 at 13:17







Please edit your question to specify the data format and the versions of software in use. You should also specify the datatype of the target column (since date fields don't have formats)

– Vince
May 7 '16 at 13:17















Please edit the question to contain the requested information. You should detail what you have tried, and exactly how it failed. This will help allow our volunteers to understand what you are trying to achieve. As it stands, there isn't enough information to more than guess at a solution -- I'm imagining an autopopulate column in DB2 isn't going to meet your needs.

– Vince
May 7 '16 at 16:41





Please edit the question to contain the requested information. You should detail what you have tried, and exactly how it failed. This will help allow our volunteers to understand what you are trying to achieve. As it stands, there isn't enough information to more than guess at a solution -- I'm imagining an autopopulate column in DB2 isn't going to meet your needs.

– Vince
May 7 '16 at 16:41













Sounds to me if you would like to store the timestamp of the last edit/update of a feature in an attribute, did I get you right? Something like what ESRI calls 'editor tracking'?

– Jochen Schwarze
May 7 '16 at 17:21





Sounds to me if you would like to store the timestamp of the last edit/update of a feature in an attribute, did I get you right? Something like what ESRI calls 'editor tracking'?

– Jochen Schwarze
May 7 '16 at 17:21




2




2





so what kind of data provider are you using (shape, postgis, ...) and by the way: is the 3-digit month a typing error or do you need something like 2016-may-08? perhaps catching the ´beforeCommitChanges´ signal of a ´QgsVectorLayer´ or an ´UPDATE´ trigger in postgesql might be successful.

– Jochen Schwarze
May 8 '16 at 9:19





so what kind of data provider are you using (shape, postgis, ...) and by the way: is the 3-digit month a typing error or do you need something like 2016-may-08? perhaps catching the ´beforeCommitChanges´ signal of a ´QgsVectorLayer´ or an ´UPDATE´ trigger in postgesql might be successful.

– Jochen Schwarze
May 8 '16 at 9:19




1




1





Shapefile is a miserable data format for timestamps, since dBase only supports day resolution (it doesn't really support NULLs either). You need to use a character column for this information (which would then need to be parsed for any further use)

– Vince
May 8 '16 at 15:10





Shapefile is a miserable data format for timestamps, since dBase only supports day resolution (it doesn't really support NULLs either). You need to use a character column for this information (which would then need to be parsed for any further use)

– Vince
May 8 '16 at 15:10










3 Answers
3






active

oldest

votes


















11














You can use the following code which connects the attributeValueChanged event to a function we can define which inserts the results of the $now expression. Highlight your layer and copy/paste the following into the Python Console:



layer = qgis.utils.iface.activeLayer()

def update():
field = layer.fieldNameIndex('mod')
e = QgsExpression( " $now " )
e.prepare( layer.pendingFields() )
for feat in layer.selectedFeatures():
feat[field] = e.evaluate( feat )
layer.updateFeature( feat )

layer.attributeValueChanged.connect(update)


Select the feature by clicking the row number (shown in the red box in the image) or from the map canvas and edit any attribute for that feature. The attribute in your mod field should update:



Result





Note: I used a string field instead of date in order to get the time, otherwise the date field only records YYYY-MM-DD.






share|improve this answer


























  • @CarlosPires - Most welcome! Hope it helps :)

    – Joseph
    May 10 '16 at 9:04











  • so I created a new text string(20) field 'mod' (see 1), I pasted your code into the Python console (after ctrl-alt-P), insert the name of the street 'name' (see 2), left the record but the field is still NULL (see 3) as you see in the screen capture. ![ScreenshotTry] (i.stack.imgur.com/lGR2D.png).

    – Carlos Pires
    May 10 '16 at 21:35








  • 2





    Now it works! As I am not a programmer did not know we had first run the code !! :( Sorry. Note:It works with the select tool. If the attribute field is edited with the info tool (identify feature), it doesn´t work.

    – Carlos Pires
    May 11 '16 at 14:32






  • 2





    @CarlosPires You can use the AutoFields plugin for this. Watch this video for an example of automatic calculation of date and time. I guess it should also work if you use the identify tool to update your values, could you please check?

    – Germán Carrillo
    Aug 19 '16 at 16:44






  • 1





    @GermánCarrillo, it seems a good choice. I will try later. Thanks.

    – Carlos Pires
    Aug 21 '16 at 12:05



















3














I stumbled upon this Q&A while I was looking for a way to date/time stamp changes I was making to records using a plugin. I placed a slightly modified version of the code into the plugin to automatically update the date/time into the record(s) I changed:



""" Prepare Change Date/Time Stamp"""
e = QgsExpression( " $now " )
cDate = e.evaluate()

"""" Identify column(s) to change and new value(s) to assign"""
attrs = { 10 : newStat, 20 : cDate }

""" Make record change and capture date/time of change'''
layer.dataProvider().changeAttributeValues({ fid : attrs })





share|improve this answer


























  • Technically this seems not to be an answer but I think this "answer" may have some value to a future reader as part of the Q&A and so I am leaving it in place. It needs more formatting than converting it to a comment would allow. I'm happy to be overruled if anyone closer to writing QGIS Plug-ins than I am wants to make a case in comments here and then ping me or another moderator.

    – PolyGeo
    Sep 4 '16 at 21:49



















0














Most updated appkication to locate exact place time






share|improve this answer








New contributor




Alonzo Charles is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "79"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f192674%2fmaking-automatic-updated-date-and-time-field-in-qgis%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    11














    You can use the following code which connects the attributeValueChanged event to a function we can define which inserts the results of the $now expression. Highlight your layer and copy/paste the following into the Python Console:



    layer = qgis.utils.iface.activeLayer()

    def update():
    field = layer.fieldNameIndex('mod')
    e = QgsExpression( " $now " )
    e.prepare( layer.pendingFields() )
    for feat in layer.selectedFeatures():
    feat[field] = e.evaluate( feat )
    layer.updateFeature( feat )

    layer.attributeValueChanged.connect(update)


    Select the feature by clicking the row number (shown in the red box in the image) or from the map canvas and edit any attribute for that feature. The attribute in your mod field should update:



    Result





    Note: I used a string field instead of date in order to get the time, otherwise the date field only records YYYY-MM-DD.






    share|improve this answer


























    • @CarlosPires - Most welcome! Hope it helps :)

      – Joseph
      May 10 '16 at 9:04











    • so I created a new text string(20) field 'mod' (see 1), I pasted your code into the Python console (after ctrl-alt-P), insert the name of the street 'name' (see 2), left the record but the field is still NULL (see 3) as you see in the screen capture. ![ScreenshotTry] (i.stack.imgur.com/lGR2D.png).

      – Carlos Pires
      May 10 '16 at 21:35








    • 2





      Now it works! As I am not a programmer did not know we had first run the code !! :( Sorry. Note:It works with the select tool. If the attribute field is edited with the info tool (identify feature), it doesn´t work.

      – Carlos Pires
      May 11 '16 at 14:32






    • 2





      @CarlosPires You can use the AutoFields plugin for this. Watch this video for an example of automatic calculation of date and time. I guess it should also work if you use the identify tool to update your values, could you please check?

      – Germán Carrillo
      Aug 19 '16 at 16:44






    • 1





      @GermánCarrillo, it seems a good choice. I will try later. Thanks.

      – Carlos Pires
      Aug 21 '16 at 12:05
















    11














    You can use the following code which connects the attributeValueChanged event to a function we can define which inserts the results of the $now expression. Highlight your layer and copy/paste the following into the Python Console:



    layer = qgis.utils.iface.activeLayer()

    def update():
    field = layer.fieldNameIndex('mod')
    e = QgsExpression( " $now " )
    e.prepare( layer.pendingFields() )
    for feat in layer.selectedFeatures():
    feat[field] = e.evaluate( feat )
    layer.updateFeature( feat )

    layer.attributeValueChanged.connect(update)


    Select the feature by clicking the row number (shown in the red box in the image) or from the map canvas and edit any attribute for that feature. The attribute in your mod field should update:



    Result





    Note: I used a string field instead of date in order to get the time, otherwise the date field only records YYYY-MM-DD.






    share|improve this answer


























    • @CarlosPires - Most welcome! Hope it helps :)

      – Joseph
      May 10 '16 at 9:04











    • so I created a new text string(20) field 'mod' (see 1), I pasted your code into the Python console (after ctrl-alt-P), insert the name of the street 'name' (see 2), left the record but the field is still NULL (see 3) as you see in the screen capture. ![ScreenshotTry] (i.stack.imgur.com/lGR2D.png).

      – Carlos Pires
      May 10 '16 at 21:35








    • 2





      Now it works! As I am not a programmer did not know we had first run the code !! :( Sorry. Note:It works with the select tool. If the attribute field is edited with the info tool (identify feature), it doesn´t work.

      – Carlos Pires
      May 11 '16 at 14:32






    • 2





      @CarlosPires You can use the AutoFields plugin for this. Watch this video for an example of automatic calculation of date and time. I guess it should also work if you use the identify tool to update your values, could you please check?

      – Germán Carrillo
      Aug 19 '16 at 16:44






    • 1





      @GermánCarrillo, it seems a good choice. I will try later. Thanks.

      – Carlos Pires
      Aug 21 '16 at 12:05














    11












    11








    11







    You can use the following code which connects the attributeValueChanged event to a function we can define which inserts the results of the $now expression. Highlight your layer and copy/paste the following into the Python Console:



    layer = qgis.utils.iface.activeLayer()

    def update():
    field = layer.fieldNameIndex('mod')
    e = QgsExpression( " $now " )
    e.prepare( layer.pendingFields() )
    for feat in layer.selectedFeatures():
    feat[field] = e.evaluate( feat )
    layer.updateFeature( feat )

    layer.attributeValueChanged.connect(update)


    Select the feature by clicking the row number (shown in the red box in the image) or from the map canvas and edit any attribute for that feature. The attribute in your mod field should update:



    Result





    Note: I used a string field instead of date in order to get the time, otherwise the date field only records YYYY-MM-DD.






    share|improve this answer















    You can use the following code which connects the attributeValueChanged event to a function we can define which inserts the results of the $now expression. Highlight your layer and copy/paste the following into the Python Console:



    layer = qgis.utils.iface.activeLayer()

    def update():
    field = layer.fieldNameIndex('mod')
    e = QgsExpression( " $now " )
    e.prepare( layer.pendingFields() )
    for feat in layer.selectedFeatures():
    feat[field] = e.evaluate( feat )
    layer.updateFeature( feat )

    layer.attributeValueChanged.connect(update)


    Select the feature by clicking the row number (shown in the red box in the image) or from the map canvas and edit any attribute for that feature. The attribute in your mod field should update:



    Result





    Note: I used a string field instead of date in order to get the time, otherwise the date field only records YYYY-MM-DD.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited May 9 '16 at 14:54

























    answered May 9 '16 at 12:08









    JosephJoseph

    58.8k7102207




    58.8k7102207













    • @CarlosPires - Most welcome! Hope it helps :)

      – Joseph
      May 10 '16 at 9:04











    • so I created a new text string(20) field 'mod' (see 1), I pasted your code into the Python console (after ctrl-alt-P), insert the name of the street 'name' (see 2), left the record but the field is still NULL (see 3) as you see in the screen capture. ![ScreenshotTry] (i.stack.imgur.com/lGR2D.png).

      – Carlos Pires
      May 10 '16 at 21:35








    • 2





      Now it works! As I am not a programmer did not know we had first run the code !! :( Sorry. Note:It works with the select tool. If the attribute field is edited with the info tool (identify feature), it doesn´t work.

      – Carlos Pires
      May 11 '16 at 14:32






    • 2





      @CarlosPires You can use the AutoFields plugin for this. Watch this video for an example of automatic calculation of date and time. I guess it should also work if you use the identify tool to update your values, could you please check?

      – Germán Carrillo
      Aug 19 '16 at 16:44






    • 1





      @GermánCarrillo, it seems a good choice. I will try later. Thanks.

      – Carlos Pires
      Aug 21 '16 at 12:05



















    • @CarlosPires - Most welcome! Hope it helps :)

      – Joseph
      May 10 '16 at 9:04











    • so I created a new text string(20) field 'mod' (see 1), I pasted your code into the Python console (after ctrl-alt-P), insert the name of the street 'name' (see 2), left the record but the field is still NULL (see 3) as you see in the screen capture. ![ScreenshotTry] (i.stack.imgur.com/lGR2D.png).

      – Carlos Pires
      May 10 '16 at 21:35








    • 2





      Now it works! As I am not a programmer did not know we had first run the code !! :( Sorry. Note:It works with the select tool. If the attribute field is edited with the info tool (identify feature), it doesn´t work.

      – Carlos Pires
      May 11 '16 at 14:32






    • 2





      @CarlosPires You can use the AutoFields plugin for this. Watch this video for an example of automatic calculation of date and time. I guess it should also work if you use the identify tool to update your values, could you please check?

      – Germán Carrillo
      Aug 19 '16 at 16:44






    • 1





      @GermánCarrillo, it seems a good choice. I will try later. Thanks.

      – Carlos Pires
      Aug 21 '16 at 12:05

















    @CarlosPires - Most welcome! Hope it helps :)

    – Joseph
    May 10 '16 at 9:04





    @CarlosPires - Most welcome! Hope it helps :)

    – Joseph
    May 10 '16 at 9:04













    so I created a new text string(20) field 'mod' (see 1), I pasted your code into the Python console (after ctrl-alt-P), insert the name of the street 'name' (see 2), left the record but the field is still NULL (see 3) as you see in the screen capture. ![ScreenshotTry] (i.stack.imgur.com/lGR2D.png).

    – Carlos Pires
    May 10 '16 at 21:35







    so I created a new text string(20) field 'mod' (see 1), I pasted your code into the Python console (after ctrl-alt-P), insert the name of the street 'name' (see 2), left the record but the field is still NULL (see 3) as you see in the screen capture. ![ScreenshotTry] (i.stack.imgur.com/lGR2D.png).

    – Carlos Pires
    May 10 '16 at 21:35






    2




    2





    Now it works! As I am not a programmer did not know we had first run the code !! :( Sorry. Note:It works with the select tool. If the attribute field is edited with the info tool (identify feature), it doesn´t work.

    – Carlos Pires
    May 11 '16 at 14:32





    Now it works! As I am not a programmer did not know we had first run the code !! :( Sorry. Note:It works with the select tool. If the attribute field is edited with the info tool (identify feature), it doesn´t work.

    – Carlos Pires
    May 11 '16 at 14:32




    2




    2





    @CarlosPires You can use the AutoFields plugin for this. Watch this video for an example of automatic calculation of date and time. I guess it should also work if you use the identify tool to update your values, could you please check?

    – Germán Carrillo
    Aug 19 '16 at 16:44





    @CarlosPires You can use the AutoFields plugin for this. Watch this video for an example of automatic calculation of date and time. I guess it should also work if you use the identify tool to update your values, could you please check?

    – Germán Carrillo
    Aug 19 '16 at 16:44




    1




    1





    @GermánCarrillo, it seems a good choice. I will try later. Thanks.

    – Carlos Pires
    Aug 21 '16 at 12:05





    @GermánCarrillo, it seems a good choice. I will try later. Thanks.

    – Carlos Pires
    Aug 21 '16 at 12:05













    3














    I stumbled upon this Q&A while I was looking for a way to date/time stamp changes I was making to records using a plugin. I placed a slightly modified version of the code into the plugin to automatically update the date/time into the record(s) I changed:



    """ Prepare Change Date/Time Stamp"""
    e = QgsExpression( " $now " )
    cDate = e.evaluate()

    """" Identify column(s) to change and new value(s) to assign"""
    attrs = { 10 : newStat, 20 : cDate }

    """ Make record change and capture date/time of change'''
    layer.dataProvider().changeAttributeValues({ fid : attrs })





    share|improve this answer


























    • Technically this seems not to be an answer but I think this "answer" may have some value to a future reader as part of the Q&A and so I am leaving it in place. It needs more formatting than converting it to a comment would allow. I'm happy to be overruled if anyone closer to writing QGIS Plug-ins than I am wants to make a case in comments here and then ping me or another moderator.

      – PolyGeo
      Sep 4 '16 at 21:49
















    3














    I stumbled upon this Q&A while I was looking for a way to date/time stamp changes I was making to records using a plugin. I placed a slightly modified version of the code into the plugin to automatically update the date/time into the record(s) I changed:



    """ Prepare Change Date/Time Stamp"""
    e = QgsExpression( " $now " )
    cDate = e.evaluate()

    """" Identify column(s) to change and new value(s) to assign"""
    attrs = { 10 : newStat, 20 : cDate }

    """ Make record change and capture date/time of change'''
    layer.dataProvider().changeAttributeValues({ fid : attrs })





    share|improve this answer


























    • Technically this seems not to be an answer but I think this "answer" may have some value to a future reader as part of the Q&A and so I am leaving it in place. It needs more formatting than converting it to a comment would allow. I'm happy to be overruled if anyone closer to writing QGIS Plug-ins than I am wants to make a case in comments here and then ping me or another moderator.

      – PolyGeo
      Sep 4 '16 at 21:49














    3












    3








    3







    I stumbled upon this Q&A while I was looking for a way to date/time stamp changes I was making to records using a plugin. I placed a slightly modified version of the code into the plugin to automatically update the date/time into the record(s) I changed:



    """ Prepare Change Date/Time Stamp"""
    e = QgsExpression( " $now " )
    cDate = e.evaluate()

    """" Identify column(s) to change and new value(s) to assign"""
    attrs = { 10 : newStat, 20 : cDate }

    """ Make record change and capture date/time of change'''
    layer.dataProvider().changeAttributeValues({ fid : attrs })





    share|improve this answer















    I stumbled upon this Q&A while I was looking for a way to date/time stamp changes I was making to records using a plugin. I placed a slightly modified version of the code into the plugin to automatically update the date/time into the record(s) I changed:



    """ Prepare Change Date/Time Stamp"""
    e = QgsExpression( " $now " )
    cDate = e.evaluate()

    """" Identify column(s) to change and new value(s) to assign"""
    attrs = { 10 : newStat, 20 : cDate }

    """ Make record change and capture date/time of change'''
    layer.dataProvider().changeAttributeValues({ fid : attrs })






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Sep 4 '16 at 21:54









    PolyGeo

    53.9k1781246




    53.9k1781246










    answered Sep 4 '16 at 17:34









    rLoganrLogan

    312




    312













    • Technically this seems not to be an answer but I think this "answer" may have some value to a future reader as part of the Q&A and so I am leaving it in place. It needs more formatting than converting it to a comment would allow. I'm happy to be overruled if anyone closer to writing QGIS Plug-ins than I am wants to make a case in comments here and then ping me or another moderator.

      – PolyGeo
      Sep 4 '16 at 21:49



















    • Technically this seems not to be an answer but I think this "answer" may have some value to a future reader as part of the Q&A and so I am leaving it in place. It needs more formatting than converting it to a comment would allow. I'm happy to be overruled if anyone closer to writing QGIS Plug-ins than I am wants to make a case in comments here and then ping me or another moderator.

      – PolyGeo
      Sep 4 '16 at 21:49

















    Technically this seems not to be an answer but I think this "answer" may have some value to a future reader as part of the Q&A and so I am leaving it in place. It needs more formatting than converting it to a comment would allow. I'm happy to be overruled if anyone closer to writing QGIS Plug-ins than I am wants to make a case in comments here and then ping me or another moderator.

    – PolyGeo
    Sep 4 '16 at 21:49





    Technically this seems not to be an answer but I think this "answer" may have some value to a future reader as part of the Q&A and so I am leaving it in place. It needs more formatting than converting it to a comment would allow. I'm happy to be overruled if anyone closer to writing QGIS Plug-ins than I am wants to make a case in comments here and then ping me or another moderator.

    – PolyGeo
    Sep 4 '16 at 21:49











    0














    Most updated appkication to locate exact place time






    share|improve this answer








    New contributor




    Alonzo Charles is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.

























      0














      Most updated appkication to locate exact place time






      share|improve this answer








      New contributor




      Alonzo Charles is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.























        0












        0








        0







        Most updated appkication to locate exact place time






        share|improve this answer








        New contributor




        Alonzo Charles is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










        Most updated appkication to locate exact place time







        share|improve this answer








        New contributor




        Alonzo Charles is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        Alonzo Charles is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 22 mins ago









        Alonzo CharlesAlonzo Charles

        1




        1




        New contributor




        Alonzo Charles is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Alonzo Charles is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Alonzo Charles is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f192674%2fmaking-automatic-updated-date-and-time-field-in-qgis%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Щит и меч (фильм) Содержание Названия серий | Сюжет |...

            is 'sed' thread safeWhat should someone know about using Python scripts in the shell?Nexenta bash script uses...

            Meter-Bus Содержание Параметры шины | Стандартизация |...