Solved

Julian Date

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Familiarize people with the process of utilizing SQL Server views 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 Access…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

12 Experts available now in Live!

Get 1:1 Help Now