I have an integer stored in a database (SQLAgent Frequency Interval) This integer is actually the sum of the selected days of the week that the schedule is to run The possible v
Edit: This is C# code to do the bit operations. I posted it before reading the question in detail, but I will leave it here as an alternative. Is the database really the best place to do this...?
You can use an array:
// input: int value
string[] weekdays = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Saturday" };
int flag = 1
List days = new List();
foreach (string day in days) {
if ((value && flag) != 0) {
days.Add(day);
}
flag <<= 1;
}
The result is a list of strings, if you want to merge them you can for example do:
string selected = String.Join(", ", days.ToArray());