OK, you just want the Julian Day, aka the Day of the Year.
For that you just use a table and brute-force it to account for the number of days per month, and 28 or 29 days for February in leap years.
To remind myself of the correct number of days I rely on NASA instead of kindergarten mnemonics:
https://landweb.modaps.eosdis.nasa.gov/browse/calendar.html
Here's a little Structured Text routine that will calculate the Day of the Year:
// For use elsewhere in the program, there is a User Defined Datatype of "WCT" made up of 7 DINTs
// With the element names Year, Month, Day, Hour, Minute, Second, ms
GSV(WallClockTime,,LocalDateTime,WCT.Year) ; // Gets the current Wall Clock Time from the system clock.
Leap_Year_Remainder := WCT.Year MOD 4 ; // Leap Years are evenly divisible by 4, so the remainder will be 0 in a Leap Year
Case WCT.Month Of
1: Day_Value_temp := WCT.Day ;
2: Day_Value_temp := WCT.Day + 31 ;
3: Day_Value_temp := WCT.Day + 59 ;
4: Day_Value_temp := WCT.Day + 90 ;
5: Day_Value_temp := WCT.Day + 120 ;
6: Day_Value_temp := WCT.Day + 151 ;
7: Day_Value_temp := WCT.Day + 181 ;
8: Day_Value_temp := WCT.Day + 212 ;
9: Day_Value_temp := WCT.Day + 243 ;
10: Day_Value_temp := WCT.Day + 273 ;
11: Day_Value_temp := WCT.Day + 304 ;
12: Day_Value_temp := WCT.Day + 334 ;
Else Day_Value_temp := 0; // If somehow the WCT Month is not 1-12
End_Case;
If (Leap_Year_Remainder = 0) Then // If this is a leap year then we add 1 in all months that are not January or February
If WCT.Month > 2 Then
Julian_Day := Day_Value_temp + 1;
Else
Julian_Day := Day_Value_temp ;
End_If;
Else
Julian_Day := Day_Value_temp ; // If this is not a leap year then the date is correct without adjustment
End_If ;