Day of Week in String: A simple function

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
arjfca
Posts: 1283
Joined: 23 Nov 2010
Has thanked: 724 times
Been thanked: 222 times

Day of Week in String: A simple function

Postby arjfca » 01 Jan 2016

A simple function to return the day of the week in a long or short string

Day_Of_the_Week: Integer 0 to 6
Long_Short: String ("L" or "l") / "S" or "s"

Dayoftheweek(5,"L") = Friday
Dayoftheweek (5,"s" = Fr

Code: Select all

//DayOfTheWeek will return a string of the day of the week
//Martin Theriault
Input:
Day_Of_The_week (NumericSimple),
Long_Short (StringSimple);

If day_Of_The_Week < 7 then begin //If Day_of_the_week <7
If Long_Short =( "L") or Long_Short =( "l")then begin // If_1
Switch(Day_Of_The_week) begin //switch1
Case 0: DayOfTheWeek = "Sunday";
Case = 1: DayOfTheWeek = "Monday";
Case = 2: DayOfTheWeek = "Tuesday";
Case = 3: DayOfTheWeek = "Wednesday";
Case = 4: DayOfTheWeek = "Thursday";
Case = 5: DayOfTheWeek = "Friday";
Case = 6: DayOfTheWeek = "Saturday";
end;//switch1
end;//If_1

If Long_Short =( "S") or Long_Short =( "s")then begin // If_1_
Switch(Day_Of_The_week) begin //switch1_1
Case 0: DayOfTheWeek = "Su";
Case = 1: DayOfTheWeek = "Mo";
Case = 2: DayOfTheWeek = "Tu";
Case = 3: DayOfTheWeek = "We";
Case = 4: DayOfTheWeek = "Th";
Case = 5: DayOfTheWeek = "Fr";
Case = 6: DayOfTheWeek = "Sa";
end;//switch1_1
end;//If_1_1

end;

Return to “User Contributed Studies and Indicator Library”