## 6 replies

Last post Jan 18, 2013 02:55 PM by TheEisdame

Member

9 Points

119 Posts

### Julian Date Question

Hello world! I am praying that someone can help me understand how to convert the code below to julian date

Have created a start and end

here is the start:

Local dateVar back2;
Local dateVar back2start;
back2start := Date(Year(back2),Month(back2),01);
back2start

END

Local dateVar back2;
Local dateVar back2end;
back2end

Contributor

2070 Points

497 Posts

### Re: Julian Date Question

Hi,

Exactly one year ago, I was searching the same. Here is method to do it.

```public long Date2Julian(System.DateTime vDate)
{

return Convert.ToInt64(Strings.Format(DateAndTime.Year(vDate), "0000") + Strings.Format(DateAndTime.DateDiff("d", Convert.ToDateTime("01/01/" + Strings.Format(DateAndTime.Year(vDate), "0000")), vDate) + 1, "000"));

}```

You can comapre your results with this site:

http://aa.usno.navy.mil/data/docs/JulianDate.php

Hope it helps !

Hope this helps !

GauranG

Member

9 Points

119 Posts

### Re: Julian Date Question

Thank you very much for responding.. I am trying to teach myself Crystal Reports and this was one of the road blocks that i ran into... As side from dropping the { } do you know what else i would need to change to get that to work in a formula??

Contributor

2070 Points

497 Posts

### Re: Julian Date Question

Well, You will have to give me more details about what exactly you are trying to achieve. and how are you designing the report.

Hope this helps !

GauranG

Member

9 Points

119 Posts

### Re: Julian Date Question

My goal is to show 6 months of data so in the code below i was able to show the start and end date for each month but trying to conver that start and end into julian start and end is what i having a hard time with

Local dateVar back2;
Local dateVar back2start;
back2start := Date(Year(back2),Month(back2),01);
back2start

END

Local dateVar back2;
Local dateVar back2end;
back2end

Contributor

2070 Points

497 Posts

### Re: Julian Date Question

So if i get you right then in your database the dates are stored in julian format, right? thats why you are converting the dates in Julian and pulling the data.

Hope this helps !

GauranG

Member

9 Points

119 Posts