I have been trying to programmatically fill a datetime field using values coming from datetime.datetime.now() function.
#I create the temp shp using a URI URI = 'MultiPolygon?crs=epsg:3857&field=id:integer&field=x:integer&field=y:integer&field=z:integer&field=bx:integer&field=by:integer&field=bz:integer&field=rating:integer&field=timestamp:datetime&index=yes' # temp shp mem_layer = QgsVectorLayer(URI, 'temp', 'memory') # when I try to fill out the timestamp field with a variable now now = datetime.datetime.now() # I get an empty or zero value field
It looks like I have to cast the variable first to a string to make it work but in that case I lose the capability to make calculation over the field (I do need to keep track of time to evaluate the "duration" of a specific action triggered by the user)
I tried with the following datatypes with no luck:
Which datatype should I use when creating the shp in order for it to be filled with that specific value?