Store the day of the week and time
Posted
by
bsiddiqui
on Stack Overflow
See other posts from Stack Overflow
or by bsiddiqui
Published on 2013-11-10T21:01:13Z
Indexed on
2013/11/10
21:54 UTC
Read the original article
Hit count: 177
I have a two part question about storing day(s) of the week and time in a database. I'm using Rails 4.0, ruby 2.0.0, and postgres.
I have certain events and those events have a schedule. For the event Skydiving for example, for example, I might have Tuesday and Wednesday and 3 pm.
1) Is there a way for me to store the the record for Tuesday and Wednesday in one row or do should I have two records?
2) What is the best way to store the day and time? Is there a way to store day of week and time (not datetime) or should these be separate columns? If they should be separate, how would you store day of week? I was thinking of storing them as integer values (0 for Sunday, 1 for Monday, etc) since that's how wday method for the Time class does it.
Any suggestions would be super helpful. Thanks!
© Stack Overflow or respective owner