Re: Julian Date
- From: "Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx>
- Date: Fri, 30 Dec 2005 07:53:54 -0500
Unfortunately, "Julian date" isn't really specific: there are several
definitions.
It's also not clear to me exactly what you want your code to do: the two
snippets you've posted do different things (and, for that matter, the second
one won't work, since you've got a literal text string "NumberofDays" where
you need a numeric value: if you've got a variable named NumberofDays,
remove the quotes from around it)
Assuming your definition of Julian date is the 4 digit year followed by a 3
digit number indicating which day of the year it is, you can generate that
as a string using:
Format(MyDateField, "yyyy") & Format(DatePart("y", MyDateField), "000")
If all you want is the day number, you can use Format(MyDateField, "y") to
get a string, or DatePart("y", MyDateField) to get a number.
To convert the 3 digit number back to the date, as mentioned above you need
to use
DateSerial(Year(Date()), 1, NumberOfDays)
Post back with more details of exactly what you're trying to do.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"red skelton via AccessMonster.com" <u15475@uwe> wrote in message
news:599b7adf71d00@xxxxxx
> Hi again,
>
> I found the following exp in a search of this forum. it is:
> DateSerial(Year
> (Date()),1,"NumberofDays"), but when I try it, I get a data mis-match
> error.
> Any idea why? In my table, I have the JulDate set as text vs date so I
> would
> not think that is the problem.
>
> Thanks,
>
> Red
>
> red skelton wrote:
>>Hi everyone,
>>Trying to display a Julian date in a query. I have the VB code to change
>>a
>>calender day to a Julian, but how would I use use this code in a query?
>>The
>>VB code I have came from the Microsoft Access website and it is;
>>
>>Function CDate2Julian(MyDate As Date) As String
>>
>> CDate2Julian = Format(MyDate - DateSerial(Year(MyDate) - 1, 12, _ 31),
>>"000")
>>
>>End Function
>>
>>Can anyone tell me how this would work in a query?
>>
>>Many Thanks
>>
>>Red
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200512/1
.
- Follow-Ups:
- Re: Julian Date
- From: red skelton via AccessMonster.com
- Re: Julian Date
- References:
- Julian Date
- From: red skelton via AccessMonster.com
- Re: Julian Date
- From: red skelton via AccessMonster.com
- Julian Date
- Prev by Date: Re: Julian Date
- Next by Date: RE: Trouble with randomizing getting to Excel
- Previous by thread: Re: Julian Date
- Next by thread: Re: Julian Date
- Index(es):
Relevant Pages
|
|