A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Convert Julian to Date



 
 
Thread Tools Display Modes
  #1  
Old March 5th, 2010, 04:37 AM posted to microsoft.public.access.forms
Reggie[_4_]
external usenet poster
 
Posts: 25
Default Convert Julian to Date

Hi and TIA! I've researched and tried many many conversion functions but
none give me the results. One Example


Public Function JDatetoDate(MyDate As Integer) As Date

JDatetoDate = DateAdd("d", Right(MyDate, 3) - 1, "01/01/" &
Left(year(Now()), 3) & Left(MyDate, 1))

End Function

?JDatetoDate(8044) returned 2/13/2018 expected 2/13/2008
?JDatetoDate(0044) returned 2/13/2014 expected 2/13/2010

Any ideas. Basically want to convert a 4 digit julian to a date/time and
then I will add 1 minute to it. Thanks!

--

Reggie

  #2  
Old March 5th, 2010, 06:11 AM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Convert Julian to Date

On Thu, 4 Mar 2010 21:37:52 -0700, "Reggie"
wrote:

Hi and TIA! I've researched and tried many many conversion functions but
none give me the results. One Example


Public Function JDatetoDate(MyDate As Integer) As Date

JDatetoDate = DateAdd("d", Right(MyDate, 3) - 1, "01/01/" &
Left(year(Now()), 3) & Left(MyDate, 1))

End Function

?JDatetoDate(8044) returned 2/13/2018 expected 2/13/2008
?JDatetoDate(0044) returned 2/13/2014 expected 2/13/2010

Any ideas. Basically want to convert a 4 digit julian to a date/time and
then I will add 1 minute to it. Thanks!


You don't have a Y2K millenium problem - you have a decade problem! How do you
decide that 8 is 2008 as opposed to 2018, since the latter is in the current
decade? What would 2044 be: 2002 or 2012? How can you decide?

That said, you're applying the Left function to a Number, which won't
necessarily give you what you want. I'd use the DateSerial function instead:

DateSerial(10 * (Year(Date())\10) + Val(Left([MyDate], 1), 1,
Val(Right([MyDate], 3)))

This will return a date in the current decade. Since that isn't apparently
what you want, you may want to subtract 10 years from the first expression
under certain circumstances that you would understand better than I do!
--

John W. Vinson [MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:17 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.