pavilion Posted February 4, 2005 Report Posted February 4, 2005 Hi, I am looking for CODE "calculate the day of the year". I want to count number of day... I want to know how may day from Jan 1, to Dec 31.... Please help... Quote
Snerkel Posted February 12, 2005 Report Posted February 12, 2005 Do you need to know the current day of the year, eg a number between 1 and 366 or do you want to know how many days in a year, eg 365 or 366. Quote
b_carlton Posted February 14, 2005 Report Posted February 14, 2005 (edited) Since you didn't specify a specific AD PLC I won't give actual code. But I assume you at least have a real time clock which gives at least 'year (00-99)', 'month (1 - 12)' and 'day of month (1 - ??) Set up a table of 11 entries with the days in a month (show February as 28). You don't need an entry for December. 'Day of Year' = 0 If Month > 1 then For X = 1 to (Month - 1) 'Day Of Year' = 'Day Of Year' + table[X] Next X End If 'Day Of Year' = 'Day Of Year" + 'Day Of Month' If MOD(Year /4) = 0 AND Month > 2 then 'Day Of Year' = 'Day Of Year' + 1 End If Now - translate that into code of your target PLC. Since the Leap Year test works from 1901 through 2099 if figured that it is detailed enough. Edited February 14, 2005 by b_carlton Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.