Adding date field to attribute table using QGIS processing modeler?
I want to add a date field to my output layers attribute table, using processing modeler. I want the Date field to be a parameter in my model, because I want to manually input the Date everytime I run my model. Is there a way to do this, so the Date appears as a parameter before running the model (as shown in the picture) and the date entered then appears in the attribute table under a field titled Date. I want to give each layer I create a Date in the attribute table without having to edit the model each time.
I am new to QGIS.
In your QGIS modeler, add the Field Calculator algorithm as shown in the image below. I notice in your image that you have "Date" as a parameter name and you also want to use "Date" as a field name. Change the parameter name to another such as "Enter date", don't make it the same name.
In the Field Calculator settings, add "Date" in the Result field name option and you can type or select "Enter Date" from the dropdown menu in the Formula option:
If you use
Dateas the Field type (as in the image), the format you enter must be
'YYYY-MM-DD'(note the single quotes!). If you want to use another format then use
Stringas the Field type (remember to increase the Field length), you can then enter anything you like in whatever format you like.