Page 1 of 2 1 2 >
Topic Options
#56847 - 03/14/19 03:05 PM Julian date
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 320
Loc: Home
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
_________________________
Peace

Top
#56848 - 03/14/19 03:26 PM Re: Julian date [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 320
Loc: Home
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?
_________________________
Peace

Top
#56856 - 03/19/19 09:46 AM Re: Julian date [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 320
Loc: Home
can anyone help please ?
_________________________
Peace

Top
#56857 - 03/19/19 01:51 PM Re: Julian date [Re: Sami786]
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1926
Loc: Objectif Lune, Montreal, Qc
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);
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top
#56858 - 03/19/19 02:00 PM Re: Julian date [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 320
Loc: Home
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
_________________________
Peace

Top
#56859 - 03/19/19 02:06 PM Re: Julian date [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 320
Loc: Home
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);
_________________________
Peace

Top
#56860 - 03/19/19 02:09 PM Re: Julian date [Re: Sami786]
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1926
Loc: Objectif Lune, Montreal, Qc
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);
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top
#56861 - 03/19/19 02:18 PM Re: Julian date [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 320
Loc: Home
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?
_________________________
Peace

Top
#56862 - 03/19/19 02:31 PM Re: Julian date [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 320
Loc: Home
I got the variable but zero is missing , need your help further please

Watch.SetVariable("JDate" , diffDays );
_________________________
Peace

Top
#56864 - 03/20/19 01:17 PM Re: Julian date [Re: Sami786]
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1926
Loc: Objectif Lune, Montreal, Qc
Use this:
Code:

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

_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top
#56867 - 03/20/19 05:03 PM Re: Julian date [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 320
Loc: Home
great thank you so much
_________________________
Peace

Top
Page 1 of 2 1 2 >