I am using the time manager for a set of data and I need to create a column in my attribute table of the date in the format yyyy-mm-dd. I already have a column in my attribute table that contains Julian days (e.g. values of 1, 2, 3, etc. that I want to correspond to 2010-01-01, 2010-01-02, 2010-01-3, etc. respectively). I've tried using the field calculator to do this using Converting from Julian Date to Calendar Date? but I was unable to get an output.
Add a date field
Use Field Calculator with function editor (change the start date, dont know what you want) and press blue play button on top:
from qgis.core import * from qgis.gui import * import datetime @qgsfunction(args='auto', group='Custom') def jtogreg(x, feature, parent): startdate=datetime.datetime(2000,1,1) d=startdate+datetime.timedelta(x) return str(d)
The function can now be found under 'Custom'. Call the function:
jtogreg( "JDays" )