DATE lookup table (1990/01/01:2041/12/31)

前端 未结 4 1823
抹茶落季
抹茶落季 2021-01-23 23:17

I use a DATE\'s master table for looking up dates and other values in order to control several events, intervals and calculations within my app. It has rows for every single day

4条回答
  •  野的像风
    2021-01-23 23:51

    It depends on which database you are using. SQL Server has horrible support for temporal data and I almost always end up using a date fact table there. But databases like Oracle, Postgres and DB2 have really good support and it is typically more efficient to calculate dates on the fly for OLTP applications.

    For instance, Oracle has a last_day() function to get the last day of a month and an add_months() function to, well, add months. Typically in Oracle I'll use a pipelined function that takes start and end dates and returns a nested table of dates.

提交回复
热议问题