LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate the Day Number of the Year

Solved!
Go to solution

Hi,

I want to generate the Day Number of the Year, currently I was able to generate the day of the week of any date, input the date and the out put will be Tuesday, Monday, etc.

How can I generate the day number like  06/22/2020 = 174 or 07/01/2020  = 183 etc. and keep account of the leap year of any date? any ideas or feedback are appreciated! 

Thanks

0 Kudos
Message 1 of 7
(2,928 Views)
Solution
Accepted by topic author Aladdin2020

How old is that code? The format of the "date time rec" cluster has changed decades ago, so I recommend to use the current version.

 

See if this works for you:

 

altenbach_0-1592872061927.png

 

(I am not sure why you have a while loop without any wait. I doublet it is necessary to recalculate the same input millions of times per second)

 

Message 2 of 7
(2,914 Views)

Thank you for your help. the code is exactly what I need! 

0 Kudos
Message 3 of 7
(2,902 Views)

@altenbach wrote:

How old is that code? The format of the "date time rec" cluster has changed decades ago, so I recommend to use the current version.

 

See if this works for you:

 

altenbach_0-1592872061927.png

 

(I am not sure why you have a while loop without any wait. I doublet it is necessary to recalculate the same input millions of times per second)

 


That code could be reduced to the size of a couple of postage stamps. Somebody wise once said, do more with less. All you need is the %j specifier.

 

Snap22.png

mcduff

 

 

Message 4 of 7
(2,883 Views)

@mcduff wrote:


Snap22.png


 

How do you enter an arbitrary day/month/year into the three given controls??

(e.g. for 07/01/2020  = 183)

0 Kudos
Message 5 of 7
(2,873 Views)

@altenbach wrote:

How do you enter an arbitrary day/month/year into the three given controls??


I did not enter anything into the controls. It can be done like below, just use %j for Julian Day; this is pretty close to the OP's original request, a string result.

 

Snap23.png

mcduff

 

PS Sorry, didn't mean to insult, just some playful teasing.

0 Kudos
Message 6 of 7
(2,866 Views)

@mcduff wrote

PS Sorry, didn't mean to insult, just some playful teasing.


Oh, no insult felt here 🙂 Always enjoy creative wording. 🙂

 

I would argue that unbundling "day of year" is easier to read for most. Code size is similar. It also depends if we want a numeric or string.

 

 

Message 7 of 7
(2,858 Views)