Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-03-24
14
Medium Priority
?
3,401 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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

715 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