peacemaker Expert Licensed User Longtime User Feb 2, 2020 #1 HI, All Any help with piece of code to calculate normally the current week day starting the monday ? B4X: DateTime.GetDayOfWeek(DateTime.Now) 'returns 1 for the Sunday, but need to calculate it as 7 AHLocale lib can give FirstDayOfWeek where the monday is 2. How to calculate these all to Sunday =7 and Monday =1 ?
HI, All Any help with piece of code to calculate normally the current week day starting the monday ? B4X: DateTime.GetDayOfWeek(DateTime.Now) 'returns 1 for the Sunday, but need to calculate it as 7 AHLocale lib can give FirstDayOfWeek where the monday is 2. How to calculate these all to Sunday =7 and Monday =1 ?
Erel B4X founder Staff member Licensed User Longtime User Feb 2, 2020 #2 What exactly are looking for? You can get the day's name with DateUtils.GetDayOfWeekName. Upvote 0
peacemaker Expert Licensed User Longtime User Feb 2, 2020 #3 User's settings of various days of week: say, working days in the schedule. The interface checkboxes are fixed for the sequence from Mon. to Sun., so recalculation is required. Upvote 0
User's settings of various days of week: say, working days in the schedule. The interface checkboxes are fixed for the sequence from Mon. to Sun., so recalculation is required.
Erel B4X founder Staff member Licensed User Longtime User Feb 2, 2020 #4 Untested code: B4X: Dim d As Int = DateTime.GetDayOfWeek(DateTime.Now) - 1 Dim offset As Int = AHLocale.FirstDayOFWeek - 1 Return ((d + 7 - offset) Mod 7) + 1 Upvote 0
Untested code: B4X: Dim d As Int = DateTime.GetDayOfWeek(DateTime.Now) - 1 Dim offset As Int = AHLocale.FirstDayOFWeek - 1 Return ((d + 7 - offset) Mod 7) + 1
peacemaker Expert Licensed User Longtime User Feb 2, 2020 #5 Tested, Erel, thanks ! I tried to make this code with (Mod 7) around a hour , but failed. Upvote 0