Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

uglik's avatar
Level 3

Data type in the database for seasonal intervals

Hello everyone.

Please tell me what type of data in the database would be more correct to use.

I need to define seasonal intervals within a year. For example: Low season (September 1 - November 15, February 1 - March 15) and Medium season (November 16 - December 20) and High season (December 21 - January 31). Apply them to each current year.

Create a seasons table:

id, name, start, end, price, company_id

What is the best data type to use in a database: start and end?

Type Date: 2022-09-01 - 2022-11-15

Type Float: 09.01 - 11.15 (M.D - M.D)

Type Integer: 901 - 1115 (901/100 = 9.01 (m.d) - 1115/100 = 11.15 (m.d))

Validation: When creating a record in the database, you need to check whether the periods overlap each other.

When updating a record, ignore the current company ID

When creating a query, get prices depending on the season.

0 likes
9 replies
uglik's avatar
Level 3

@sr57 Do you check for overlapping dates, if so, please tell me how you check the month and day ranges?

sr57's avatar

@uglik

don't understand, give example.

That's said the code should check whatever you need.

uglik's avatar
Level 3

@sr57 I would like to check which days and months are occupied and the ability to create an entry only for free months and days. I am having difficulty validating dates without a year

sr57's avatar

@uglik

The easiest way to do it, test it, debug it, check for bug ... is to use a table that contains all the days of a yea and that you update when you enter a new period with a foreach.

To test the avaibility, uou do the same foreach and test from the previous table.

You can code by testing as you try, but it can be difficult to code, test ...

You can also have a look top this package https://github.com/spatie/period

To use it with "no year" just choose one "generic" ex 2000 and translate all your MMDD to 20MMDD (and some 21MMDD of course)

1 like
theryanpatterson's avatar

A good realistic fiction book typically has believable characters and a plot that could plausibly happen in the author’s life or in the life of someone the author knows. The story is often set in the author’s hometown or in a place the author is familiar with. Realistic Fiction Book often explore difficult topics and emotions, such as loss, grief, and anger.

Please or to participate in this conversation.