3

I want to use Time Manager plugin with QGIS 2.18.9 and unable to correctly format the date and assign it to a field within a table.

I have an imported table with a field called "Year Built" containing a year value as a long integer (looks like "2015"). I want to use that value in Time Manager. Time Manager needs Gregorian format YYYY-MM-DD HH:MM:SS.ssssss.

I have tried a number of ways to convert it in the expression dialog and place it in a new field called TM_Date. While in the Expression Dialog the "Output Preview" shows . But after clicking on OK and UPDATE ALL, the result in the field is a NULL value.

My last attempt was the following:

to_datetime( format_date(concat(to_string( "Year Built") ||'-01-01 01:01:01.001'),'yyyy.MM.dd HH.mm.ss.zzz'))

Not sure what I'm doing wrong here.

  • As you already have clear answer by underdark, this is just abut how to avoid NULL. On the Field calculator there is Output field type pull-down menu. You need to select Date then your expression should work. – Kazuhito Jun 2 '17 at 20:03
5

YYYY-MM-DD is supported, so this should be sufficient:

"Year Built"||'-01-01'
  • 'to_date( concat(to_string( "Year Built")||'-01-01'))' – Phil_in_Tx Jun 2 '17 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.