Solved

Julian Date

Posted on 1997-12-18
2
657 Views
Last Modified: 2007-11-15
I need a function() that can be used in an update query that  will convert an regular date that is stored in one field, to a Julian date to be stored in another field.

Thank you in advance.
0
Comment
Question by:jrd
[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
2 Comments
 
LVL 5

Accepted Solution

by:
cekman earned 100 total points
ID: 1963014
This came from MS KB article: Q162745

Hope it helps

The userdefined function CDate2Julian(), converts a date to a Julian day:
 
1. Create a module and type the following line in the Declarations section if it is not already there:
 
      Option Explicit
 
2. Type the following procedure:
 
    ' *********************************************************************
    ' FUNCTION: CDate2Julian()
    '
    ' PURPOSE: Convert a date to a Julian day. The function works with
    '          dates based on the Gregorian (modern) calendar.
    '
    ' ARGUMENTS:
    '    MyDate: A valid Microsoft Access date.
    '
    ' RETURNS: A three digit Julian day as a string.
    ' *********************************************************************
    Function CDate2Julian(MyDate As Date) As String
        CDate2Julian = Format(MyDate - DateSerial(Year(MyDate) - 1, 12, _
        31), "000")
    End Function
 
3. To test this function, type the following line in the Debug window, and
   then press ENTER:
 
      ?CDate2Julian(#3/1/1996#)
 
   Note that Julian day 061 is returned.
 
4. To convert a valid Microsoft Access date to a Julian date in a format
   like 96061 type the following line in the Debug window, and then press
   ENTER:
 
      ?Year(#3/1/1996#) Mod 100 & CDate2Julian(#3/1/1996#)
 
   Note that 96061 is returned.
 
5. To convert a valid Microsoft Access date to a Julian date in a format like 96-061 type the following line in the Debug window, and then press
   ENTER:
 
      ?Year(#3/1/1996#) Mod 100 & "-" & CDate2Julian(#3/1/1996#)

0
 

Author Comment

by:jrd
ID: 1963015
Try this...


Change:
 Function CDate2Julian(MyDate As Date) .....

To:
 Function CDate2Julian(MyDate As Variant)......
0

Featured Post

Technology Partners: 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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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 …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

738 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