If the field type is not string, then the simplest way is to create a new field with
Text type of 5 characters length. Then in the field calculator go to
Update existing field and select the newly created field. Then use the following expression:
The numbers will be truncated to the first 5 digits.
However, if the existing field is already of
Text type, then create a new field as above and use the following expression, and it will do the job:
The column in red color is the original column, and the column in green color is the selected first 5 digits.
Then use dissolve tool from
Vector -> Geoprocessing tools -> Dissolve, if you are using QGIS 2.14.7, and select the
NewField as a base to dissolve your polygons. If you are using QGIS 2.16.3, then go to
Processing toolbox -> QGIS geoalgorithms -> Vector geometry tools -> Dissolve
The output of dissolve tool using the
NewField column (in this example the column name is
EndDateSub) is as follows: