I merged 2 layers in QGIS and am trying to clean up the attribute table using the Field Calculator. One layer has 1 column called Date in the format YYYY-MM-DD. The other layer has 3 separate columns with real numbers for Month, Day, and Year. I'd like them all to be in the YYYY-MM-DD format, preferably using the Field Calculator. I'm not experienced with Python and don't know where to begin with the expression builder. So here's an example of each type of date format within the same layer.
You can clean up the attribute table using the Field Calculator in the next way:
Update your fields using the following expressions:
# Date to year, mount, day year("Date") month("Date") day("Date" ) # day, month, year to date to_date(to_int("Day") || '/' || to_int("Month") || '/' || to_int("Year"),'d/M/yyyy')
To calculate the date you can use the following function
To have more information about the date format you can check https://doc.qt.io/qt-5/qdate.html#fromString-1
Calculate the month from the date: