Skip to main content
added 226 characters in body
Source Link
jlSta
  • 1.1k
  • 8
  • 30

More simple than other solutions, use Field Calculator functions (QGIS 2.18 maybe under): to_date(string) and format_date(datetime, format)

  1. If '/' use regexp_replace( '2012/05/04' ,'/','-')
  2. to_date('2012-05-04') → 2012-05-04
  3. format_date('2012-05-15','dd.MM.yyyy') → '15.05.2012'

If you have problem with international date format you can use substring to convert:

format_date( to_date(  '20'||substr( "date_field" ,7,2) ||'-'||substr( "date_field" ,4,2) ||'-'||substr("date_field" ,1,2)),'yyyy-MM-dd')

More simple than other solutions, use Field Calculator functions (QGIS 2.18 maybe under): to_date(string) and format_date(datetime, format)

  1. If '/' use regexp_replace( '2012/05/04' ,'/','-')
  2. to_date('2012-05-04') → 2012-05-04
  3. format_date('2012-05-15','dd.MM.yyyy') → '15.05.2012'

More simple than other solutions, use Field Calculator functions (QGIS 2.18 maybe under): to_date(string) and format_date(datetime, format)

  1. If '/' use regexp_replace( '2012/05/04' ,'/','-')
  2. to_date('2012-05-04') → 2012-05-04
  3. format_date('2012-05-15','dd.MM.yyyy') → '15.05.2012'

If you have problem with international date format you can use substring to convert:

format_date( to_date(  '20'||substr( "date_field" ,7,2) ||'-'||substr( "date_field" ,4,2) ||'-'||substr("date_field" ,1,2)),'yyyy-MM-dd')
added 54 characters in body
Source Link
jlSta
  • 1.1k
  • 8
  • 30

More simple than other solutions, use Field Calculator functions (QGIS 2.18 maybe under): to_date(string) and format_date(datetime, format)

  1. If '/' use regexp_replace( '2012/05/04' ,'/','-')
  2. to_date('2012-05-04') → 2012-05-04
  3. format_date('2012-05-15','dd.MM.yyyy') → '15.05.2012'

More simple than other solutions, use Field Calculator functions (QGIS 2.18): to_date(string) and format_date(datetime, format)

  1. to_date('2012-05-04') → 2012-05-04
  2. format_date('2012-05-15','dd.MM.yyyy') → '15.05.2012'

More simple than other solutions, use Field Calculator functions (QGIS 2.18 maybe under): to_date(string) and format_date(datetime, format)

  1. If '/' use regexp_replace( '2012/05/04' ,'/','-')
  2. to_date('2012-05-04') → 2012-05-04
  3. format_date('2012-05-15','dd.MM.yyyy') → '15.05.2012'
Source Link
jlSta
  • 1.1k
  • 8
  • 30

More simple than other solutions, use Field Calculator functions (QGIS 2.18): to_date(string) and format_date(datetime, format)

  1. to_date('2012-05-04') → 2012-05-04
  2. format_date('2012-05-15','dd.MM.yyyy') → '15.05.2012'