Hi all,

I want to store the hours of restaurants in a database (sounds simple, right?). I don't want a text field where hours are entered as a lump of data, but was thinking of making a column for each day of the week and filling in the hours this way. I was planning on doing something like this...

hours_sunday_open
hours_sunday_close
hours_monday_open
etc, etc,

Then I realized, what if the restaurant is open from say 4PM on Friday and doesn't close until 2am Saturday? This method won't work so well.

Any idea how I can store the open/close times taking the above problem into account?

It is not an option to just have a varchar or text column labeled hours. I'd much rather list each day separately for search purposes.

Thanks

There are a few different ways you can approach this.
You can still use your original concept, when validating the data for display, if the close value is less than the open, then obviously it is the next day. That seems to be the easiest, as long as the data has to stay in the db.

There are other ways but I think the above concept is sound.

There are a few different ways you can approach this.
You can still use your original concept, when validating the data for display, if the close value is less than the open, then obviously it is the next day. That seems to be the easiest, as long as the data has to stay in the db.

There are other ways but I think the above concept is sound.

thanks for the input. i'll stick with my original idea.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.