This is the PLC code that I use to calculate the Julian date:
' GenJD - custom function to compute Julian Date.
' Algorithm agrees with USNO (United States Naval Observatory) online Julian Date Converter
' at http://aa.usno.navy.mil/data/docs/JulianDate.php
'
' 9/17/2013 is JD 2456553
'
' On entry:
' I = year 2013
' J = month 1..12
' K = day of month
'
' On exit:
' A holds Julian date
'
A = K-32075+1461*(I+4800+(J-14)/12)/4+367*(J-2-(J-14)/12*12) /12-3*((I+4900+(J-14)/12)/100)/4
[/color]
I didn't write this stuff, I just trans-coded it form FORTRAN to TBASIC.
OK how to you use it to calculate how many days into 2018 the date, February 1 occurs.
Set: I = 2018 ' year
Set: J = 2 ' month
Set: K = 1 ' day
Then run the algorithm. The answer should be 2458150.
Now calculate the Julian date for January 1, 2018. This answer should be 2458119.
Now you can calculate how many days into 2018 February 1st is by a bit of subtraction:
31 = 2458150 - 2458119
Now you know that you February 1, 2018 is the 31 day in 2018 (the first day is day 0).
And if you will find that a bit of division will give you the week into 2018 that February 1 is the 5th week in 2018:
5 = 31 / 7 + 1
Pretty slick.
If you definition of week number is for weeks that start on a set day like Monday, then you will need to adjust the algorithm. 2018 started on a Monday, but 2019 will not.
Work weeks or factory weeks, usually, have some interesting rules. Google "ISO 8601" for the international standards for counting weeks within a year. I'll bet you didn't know the first week in the year must have a Thursday...otherwise the first few days of the year belong to the last week of the previous year. Obviously!
I'll give you a bit of a hint about what you might consider. The Julian date algorithm starts at the following date: Tuesday, 4713 B.C. Jan 2
Day 0 was Tuesday. Every seven days since Day 0 will be a Tuesday. So you can take any Julian date and MOD it by 7 and the resulting value (0..7) will represent the days Tuesday, Wednesday..Monday.
Best regards
Gary D*ckinson