I'm pretty new to QGIS3.4 and I would like to ask how could I visualize the business operation time (opening/closing) over the course of a week.

I know that I could input an time in the data attributes but how can I input a data of time over the course of the week with some exception in closing-opening time like the store closes on Sunday,or the there are some different opening-closing time each days.

1 Answer 1


The right way is probably to create a child (related) table with a record for each opening interval. For example:

Main (store) table: 
| id | name |
| 1  | Foo  |
| 2  | Bar  |

opening hours table:
| id | store_id | day | open  | close |
| 1  | 1        | 1   | 07:00 | 17:00 |
| 2  | 1        | 2   | 07:00 | 17:00 |
| 3  | 2        | 6   | 19:00 | 23:00 |

That way each store can have different opening hours thru the course of the week, or even multiple opening hours during the day (eg. lunch break). This approach works best if you store data in a database (PostGIS, MSSQL, etc.) because it provides a pretty flexible way how to query and analyze data in that structure (filtering, grouping, aggregating to strings and so on).

Then you can load these tables into QGIS, create a relation between them and use a table relation widget to edit opening hours directly on main (store) feature form.

A simpler way is to describe opening hours as plain text in the store table (eg sa-su: 08:00 - 12:00, mo-fr: 07:00 - 15:00). Then it's pretty easy to edit and visualise this, but it lacks analytical capabilities and it's prone to errors ('mo-fr' vs 'mo- fr' vs 'mo - fr').

So... if you want to build robust database with full capabilities, then definitely pick first approach (or some variant of it). If you have few stores, or if it is a "single shot" kind of project, then maybe relation approach is a bit of overkill and simple string representation will be sufficient. But, chose wisely, because "simple and dirty" approaches tend to kick you in the ass later on ;)

  • Thanks David ! So if already have edited some basic datas in qgis such as store_id, could I still add a time attributes later in postgis ?
    – Koup ADoop
    Commented Jun 26, 2019 at 9:01
  • Of course, you can!
    – DavidP
    Commented Jun 26, 2019 at 9:07
  • If you did want to model it as a string (which has the advantage of allowing you to use only a single field and does not depend on a second table), you could consider how OpenStreetMap approaches the problem. Just a warning that as complex as you think it is, it's potentially exponentially more complex again. Example: "Mo-Sa 08:00-13:00,14:00-17:00; PH off". wiki.openstreetmap.org/wiki/Key:opening_hours Actually parsing that back out into something easy to visualise is hard too, but people have made libraries: pypi.org/project/osm-humanized-opening-hours Commented Jun 30, 2019 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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