Reputation: 131
For example I have:
How do I define the week so I can store the above data in a 3 field in the database?
Upvotes: 0
Views: 69
Reputation: 2616
From a processing perceptive, storing those 3 fields in a single cell is not recommended. You would have to go through unnecessary overhead to encode and decode the data while writing to and reading from the table and also would need to perform additional data-type conversions!
You could try something like : ,, Where : 124 for Monday, Tuesday and Thursday. But as discussed above, it is not the right way to go about it..
Ideally you have 3 columns for each item and store the weekdays in a number of formats:
<weekday_list_to_run_the _scheduled_tasks>
: Where we encode Monday,
Tuesday and Thursday
as 124
. Requires the most processing.<weekday_list_to_run_the _scheduled_tasks> = Monday-X-X-Thursday-Fri-X-Sunday
as 1001101
.
Then through 7 AND-ing operations we find the days on which the
schedule should run.Eg.
IF (<weekday_list_to_run_the _scheduled_tasks> AND 1000000) == 1 THEN
//Monday is set.
END IF
Upvotes: 1