Returning week number of the month

4

In January this year (2018) I have 5 weeks in it, being:

1 week: 1 to 7;

2 weeks: 8 to 14;

3 weeks: 15 to 21;

4 weeks: 22 to 28 and

5 weeks: 29 to 31 (or for others from 29 to 04 February).

When I use the function WeekOfTheYear the application returns me day 29 as being week 1, which is not true.

Any solutions to this problem?

    
asked by anonymous 30.01.2018 / 13:30

1 answer

5

Maybe this might help you:

weekNum: Integer; 
weekNum:=(StrToInt(FormatDateTime('dd',Date)) - 1) div 7 + 1 ;
    
30.01.2018 / 14:10