Friday 20 September 2019

Storing datetime values in Shapefiles using QGIS?


I have a shapefile with date in a string field. I create a new field with date type and use the calculator to make the conversion. But the result only provide the date part, the time part is removed. Even when the preview show the correct conversion.


Here you can see the original string field time and the result date time2. And the use of the conversion function to_datetime() and the preview result at the end


enter image description here


If you go to the layer properties you can change the edit mode to date/time. Then if go to the data and try to edit time2 you get the current date/time. So is possible save date and time in the same field. But the update tool still doesn't work as expected


enter image description here





As J.R said. Even when you can change QGIS edit to allow Date/Time the save to shapefile will discard the time.



Answer



As joseph said in comment you can't store date and time in a single field of a shapefile, you could :


-use a string field (as Joseph said)


-use two field (one for date and one for time...)


-use another file format that support DateTime fieldtype to store your data


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...