Julian date

Posted by: Sami786

Julian date - 03/14/19 03:05 PM

Hi, Anyone Is it possible to work out the Julian date, I need to add Julian date on each output file.
For now I'm doing this manually to each file.

This will save me a lot of time. Your help is greatly appreciated.

THANKS
Posted by: Sami786

Re: Julian date - 03/14/19 03:26 PM

this is the formula in Excel but it's not working either

=RIGHT(YEAR(A4),2)& A4-DATE(YEAR(A4),1,0) it gives me 191 for todays date instead of 73.

Can someone convert the above formula in VBScript or java?
Posted by: Sami786

Re: Julian date - 03/19/19 09:46 AM

can anyone help please ?
Posted by: Philippe F.

Re: Julian date - 03/19/19 01:51 PM

This bit of JavaScript code does the trick:
Code:
var firstDate= new Date();
var secondDate= new Date(firstDate.getYear(),0,1);

var diffDays = Math.floor((firstDate.getTime() - secondDate.getTime()) / (1000 * 3600 * 24));
var julianDate = firstDate.getYear().toString().slice(-2)+""+diffDays;

Watch.Log(julianDate,2);
Posted by: Sami786

Re: Julian date - 03/19/19 02:00 PM

Thank you Philippe, When I run the above code I get 1977. Today Julian date is 078. Can you change the code to read 078 I don't need the year. Then How can I save this value into a variable so I can print it on the file name.

THANKS
Posted by: Sami786

Re: Julian date - 03/19/19 02:06 PM

I edited the code and I get 77 now but I need to get 078

var firstDate= new Date();
var secondDate= new Date(firstDate.getYear(),0,1);

var diffDays = Math.floor((firstDate.getTime() - secondDate.getTime()) / (1000 * 3600 * 24));
var julianDate = diffDays;

Watch.Log(julianDate,2);
Posted by: Philippe F.

Re: Julian date - 03/19/19 02:09 PM

Try this:
Code:
var firstDate= new Date();
var secondDate= new Date(firstDate.getYear()-1,11,31);

var diffDays = Math.floor((firstDate.getTime() - secondDate.getTime()) / (1000 * 3600 * 24));
Watch.Log(diffDays,2);
Posted by: Sami786

Re: Julian date - 03/19/19 02:18 PM

YES, this work and give me 78, I need 3 digits, how can I add zero at the front to look like 078 and when it's over 99 it should print 100, 101 and so on.

I have a variable called JDate, I don't know in Java how to pass the value to this variable?
Posted by: Sami786

Re: Julian date - 03/19/19 02:31 PM

I got the variable but zero is missing , need your help further please

Watch.SetVariable("JDate" , diffDays );
Posted by: Philippe F.

Re: Julian date - 03/20/19 01:17 PM

Use this:
Code:

Watch.SetVariable("JDate" , ("0"+diffDays).slice(-3));

Posted by: Sami786

Re: Julian date - 03/20/19 05:03 PM

great thank you so much