Solved

Convert 7 Digit Julian Date To A Calendar Date MMDDYYYY in a Access Query

Posted on 2014-03-24
14
3,112 Views
Last Modified: 2014-03-25
I have a 7 digit number stored in a text field that is actually a Julian Date that needs to be converted to a calendar date, format mmddyyyy in a Microsoft Access Query.
0
Comment
Question by:rjordanbots
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
  • +1
14 Comments
 
LVL 3

Expert Comment

by:englanddg
ID: 39952256
Try using DateSerial(Left([FieldName],2),1,Right([FieldName],3))
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39952273
are you sure that what you have are Julian dates?
post sample values.
you can use this code for conversion

Function CJulian2Date (JulDay As Integer, Optional YYYY)
    If IsMissing(YYYY) Then YYYY = Year(Date)
    If Not IsNumeric(YYYY) Or YYYY \ 1 <> YYYY Or YYYY < 100 Or YYYY _
      > 9999 Then Exit Function
    If JulDay > 0 And JulDay < 366 Or JulDay = 366 And _
      YYYY Mod 4 = 0 And YYYY Mod 100 <> 0 Or YYYY Mod 400 = 0 Then _
        CJulian2Date = Format(DateSerial(YYYY, 1, JulDay), "m/d/yyyy")
End Function


'    JulDay: The ordinal day of a year. Between 1 and 365 for all
'            years, or between 1 and 366 for leap years.
'
'    YYYY: A three or four digit integer for a year that is within the
'          range of valid Microsoft Access dates. If YYYY is omitted,
'          then YYYY is assumed to be the year of the current system
'          date.
'

codes taken from this link
0
 
LVL 12

Expert Comment

by:KRUNAL TAILOR
ID: 39952282
Hi rjordanbots,

select DateSerial(Left([JulianField],2),1,Right([JulianField],3))
from table
 
You can also write a function in your database. like this_

Function JulianToDate(JulianDate As String) As Date

  Dim astrDatePart() As String
  
  astrDatePart = Split(JulianDate, ".")
  
  JulianToDate = DateSerial(CInt(astrDatePart(0)), 1, CInt(astrDatePart(1)))

End Function

Open in new window



Then in the query we can use the function directly.
 
select JulianToDate(table.[Myfield])
from table

More Refrence here: http://support.microsoft.com/kb/162745

Thanks & Regards,
Krunal T. Tailor
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Author Comment

by:rjordanbots
ID: 39952285
Can you tell me what Julian Date 2032306 should convert to ?

I believe it should be 11012032
0
 
LVL 12

Expert Comment

by:KRUNAL TAILOR
ID: 39952294
Hi rjordanbots,

Please check over here http://aa.usno.navy.mil/data/docs/JulianDate.php

There are so many online converter available like_
1) http://www.onlineconversion.com/julian_date.htm
2) http://www.aavso.org/jd-calculator

Thanks & Regards,
Krunal T. Tailor
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39952295
if that (2032306) is a julian date the conversion is 7/22/2306 using the function above
0
 

Author Comment

by:rjordanbots
ID: 39952307
This number is coming off of a Ibm I-Series MainFrame. I believe the first four digits is the year then the last three is the number of days. Can this be converted in Access to an actual date ?
0
 
LVL 3

Expert Comment

by:englanddg
ID: 39952308
If you have Julien dates...@Krunal has your solution.

That code is solid.
0
 
LVL 3

Expert Comment

by:englanddg
ID: 39952310
Oh, data dump?

Yes.  Use the right and left functions.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39952315
believe the first four digits is the year then the last three is the number of days. Can this be converted in Access to an actual date ? Yes

using the function

CJulian2Date(306,2032)

the value will be  11/1/2032
0
 
LVL 12

Expert Comment

by:KRUNAL TAILOR
ID: 39952322
Yes,  Rey Obrero is correct.

Please check here more ref: http://support.microsoft.com/kb/162745
Something like this:

CJulian2Date(32, 1996)
Note that your system's date format for 2/1/96 is returned. If your system's date is in 1996 then CJulian2Date(32) will also return 2/1/96.

Thanks & Regards,
Krunal T. Tailor
0
 

Author Comment

by:rjordanbots
ID: 39952326
The first four digits is the year 2032, the last 3 are the # of days, which is 306, need to convert the last 3 digits, which appears to be the julian day to an actual date

The date should read 11012032
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39952372
<The date should read 11012032 >

in the function above

change this line

        CJulian2Date = Format(DateSerial(YYYY, 1, JulDay), "m/d/yyyy")

with

        CJulian2Date = Format(DateSerial(YYYY, 1, JulDay), "mmddyyyy")
0
 

Author Closing Comment

by:rjordanbots
ID: 39954124
Thanks for your help, all of this information was very helpful.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question