Solved

Julian Date

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

911 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now