Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Julian Date

Posted on 1997-12-18
2
Medium Priority
?
673 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 400 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

772 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