QGIS Temporal Controller – How to Fix Incorrect Date Display in QGIS Temporal Controller

qgistemporal-controller

At 3.26.2, the Temporal Controller is shifting the displayed date one day later than the database date.

The screenshot below shows the QDate field __inspection_date in the point layer's attribute table. Note that its earliest date is May 26:

enter image description here

The next screenshot shows the layer's Temporal Control properties, using __inspection_date with a duration of 1 day:

enter image description here

I'm using a View > Decorations > Title Label to display the date at the bottom of the map screen, using these settings:

enter image description here

Finally, here is the main map, with the Animation Range starting at the earliest date in the database, May 26.

However, note that the date at the bottom of the screen displays one day later, May 27.

Furthermore, this one-day offset continues to occur as the controller sequences from one day to the next.

enter image description here

I've changed a variety of settings, to no avail. In particular, I changed the Decorations title to [%format_date(@map_start_time,'MMMM dd')%], but that resulted in the earliest date, May 26, displayed for every sequence, without change. In other words, it stays stuck at May 26.

Question:

How to prevent the Temporal Controller from offsetting the displayed date by one day later than the database date?

Best Answer

Solution

Change the expression by subtracting one second from the variable @map_end_time:

 format_date (@map_end_time - to_interval ('1 second') , 'MMMM dd')

What the problem was

The problem has to do with the fact that you have set the step of each frame to be 1 day (exactly this part is cut on your screenshot).

So the very first frame of the animation is from 2022-05-26 00:00:00 to 2022-05-27 00:00:00 (as can be seen on your screenshot): thus technically, the end of the frame is the beginning of the next day. If you subtract one second, you are on 2022-05-26 23:59:59 and like this still in May 26.

Related Question