Solved

Julian Date

Posted on 1997-12-18
2
656 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
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

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…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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…

762 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