<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://ocotal.iarc.uaf.edu/index.php?action=history&amp;feed=atom&amp;title=Regular_Date_to_Julian_Converter</id>
	<title>Regular Date to Julian Converter - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://ocotal.iarc.uaf.edu/index.php?action=history&amp;feed=atom&amp;title=Regular_Date_to_Julian_Converter"/>
	<link rel="alternate" type="text/html" href="http://ocotal.iarc.uaf.edu/index.php?title=Regular_Date_to_Julian_Converter&amp;action=history"/>
	<updated>2026-05-12T22:05:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>http://ocotal.iarc.uaf.edu/index.php?title=Regular_Date_to_Julian_Converter&amp;diff=471&amp;oldid=prev</id>
		<title>imported&gt;Bob at 19:28, 12 March 2008</title>
		<link rel="alternate" type="text/html" href="http://ocotal.iarc.uaf.edu/index.php?title=Regular_Date_to_Julian_Converter&amp;diff=471&amp;oldid=prev"/>
		<updated>2008-03-12T19:28:02Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Copy and paste the text in the box into the visual basic editor that comes with Excel.  To get access to personal.xls in the visual basic editor check out this article: [[Save_Macros_in_Excel]]&lt;br /&gt;
&lt;br /&gt;
This short program takes date &amp;amp; time cells and converts it to Julian days.  An additional option is a Julian Decimal day, which converts the time into a decimal quantity.  There are several important parameters you may need to edit to get things working specifically these:&lt;br /&gt;
  startrow = 13&lt;br /&gt;
  outcol = 1&lt;br /&gt;
  datecol = 2&lt;br /&gt;
  Worksheetz = 1&lt;br /&gt;
  decimalday = True&lt;br /&gt;
&lt;br /&gt;
'''startrow''' -- this is the starting row, the first line in the excel worksheet there is a date to be converted from Julian to regular.&amp;lt;br&amp;gt;&lt;br /&gt;
'''outcol''' -- this is the output column, the column you want the resulting date to be put into.  A = 1, B = 2 etc.&amp;lt;br&amp;gt;&lt;br /&gt;
'''datecol''' -- this is the column the Time &amp;amp; Date are in&amp;lt;br&amp;gt;&lt;br /&gt;
'''Worksheetz''' -- this is the excel worksheet number of the data you wish to calculate dates for.  If you have a mix of charts and worksheets in your excel file worksheet #1 is treated as the leftmost worksheet on the bar along the bottom of the spreadsheet.&amp;lt;br&amp;gt;&lt;br /&gt;
'''decimalday''' -- this boolean variable (True/False) tells the macro whether to output decimal days (as is done for some north slope sites) or an integer julian day.&lt;br /&gt;
&lt;br /&gt;
Well, with that all out of the way, here's the program.  Get a hold of Bob Busey if you have any questions or problems running this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Option Explicit&lt;br /&gt;
 Public Sub Convert_To_Julian()&lt;br /&gt;
  Dim row As Long&lt;br /&gt;
  Dim startrow As Long&lt;br /&gt;
  Dim theyear As Double&lt;br /&gt;
  Dim themonth As Double&lt;br /&gt;
  Dim theday As Double&lt;br /&gt;
  Dim thehour As Double&lt;br /&gt;
  Dim theminute As Double&lt;br /&gt;
  Dim thedate As String&lt;br /&gt;
  Dim tempstring1() As String&lt;br /&gt;
  Dim tempstring2() As String&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  Dim leapyear As Integer&lt;br /&gt;
  Dim julianday As Double&lt;br /&gt;
  &lt;br /&gt;
  Dim Worksheetz As Integer&lt;br /&gt;
  Dim outcol As Integer&lt;br /&gt;
  Dim datecol As Integer&lt;br /&gt;
   &lt;br /&gt;
  Dim decimalday As Boolean&lt;br /&gt;
  ''''''''''''''''''''''''''&lt;br /&gt;
  '  variable initialization    '&lt;br /&gt;
  ''''''''''''''''''''''''''&lt;br /&gt;
  startrow = 13&lt;br /&gt;
  outcol = 1&lt;br /&gt;
  datecol = 2&lt;br /&gt;
  Worksheetz = 1&lt;br /&gt;
  ''''' note this decimal day.. If decimalday = true then hours &amp;amp; minutes will be tacked on&lt;br /&gt;
  ''''' if decimalday = false then the julian day will be an integer.&lt;br /&gt;
  decimalday = True&lt;br /&gt;
  ''''''''''''''''''''''''''&lt;br /&gt;
   &lt;br /&gt;
  row = startrow&lt;br /&gt;
  Do While Worksheets(Worksheetz).Cells(row, datecol).Value &amp;lt;&amp;gt; &amp;quot;&amp;quot;&lt;br /&gt;
    ' Run through and pull the time/date from the spreadsheet&lt;br /&gt;
    thedate = Worksheets(Worksheetz).Cells(row, datecol).Value&lt;br /&gt;
    &lt;br /&gt;
    ' separate out the date &amp;amp; time components individually&lt;br /&gt;
    tempstring1 = Split(Format(thedate, &amp;quot;mm/dd/yyyy&amp;quot;), &amp;quot;/&amp;quot;)&lt;br /&gt;
    tempstring2 = Split(Format(thedate, &amp;quot;hh:mm&amp;quot;), &amp;quot;:&amp;quot;)&lt;br /&gt;
    themonth = CDbl(tempstring1(0))&lt;br /&gt;
    theday = CDbl(tempstring1(1))&lt;br /&gt;
    theyear = CDbl(tempstring1(2))&lt;br /&gt;
    thehour = CDbl(tempstring2(0))&lt;br /&gt;
    theminute = CDbl(tempstring2(1))&lt;br /&gt;
    &lt;br /&gt;
    ' use the year to check for the need for a leap day&lt;br /&gt;
    If theyear Mod 4 = 0 Then&lt;br /&gt;
      leapyear = 1&lt;br /&gt;
    Else&lt;br /&gt;
      leapyear = 0&lt;br /&gt;
    End If&lt;br /&gt;
   &lt;br /&gt;
    ' Do the Julian Day calculations&lt;br /&gt;
    If themonth = 1 Then     ' JANUARY&lt;br /&gt;
      julianday = theday&lt;br /&gt;
    ElseIf themonth = 2 Then ' FEBRUARY&lt;br /&gt;
      julianday = theday + 31&lt;br /&gt;
    ElseIf themonth = 3 Then ' MARCH&lt;br /&gt;
      julianday = theday + 31 + 28 + leapyear&lt;br /&gt;
    ElseIf themonth = 4 Then ' APRIL&lt;br /&gt;
      julianday = theday + 31 + 28 + leapyear + 31&lt;br /&gt;
    ElseIf themonth = 5 Then ' MAY&lt;br /&gt;
      julianday = theday + 31 + 28 + leapyear + 31 + 30&lt;br /&gt;
    ElseIf themonth = 6 Then ' JUNE&lt;br /&gt;
      julianday = theday + 31 + 28 + leapyear + 31 + 30 + 31&lt;br /&gt;
    ElseIf themonth = 7 Then ' JULY&lt;br /&gt;
      julianday = theday + 31 + 28 + leapyear + 31 + 30 + 31 + 30&lt;br /&gt;
    ElseIf themonth = 8 Then ' AUGUST&lt;br /&gt;
      julianday = theday + 31 + 28 + leapyear + 31 + 30 + 31 + 30 + 31&lt;br /&gt;
    ElseIf themonth = 9 Then ' SEPTEMBER&lt;br /&gt;
      julianday = theday + 31 + 28 + leapyear + 31 + 30 + 31 + 30 + 31 + 31&lt;br /&gt;
    ElseIf themonth = 10 Then ' OCTOBER&lt;br /&gt;
      julianday = theday + 31 + 28 + leapyear + 31 + 30 + 31 + 30 + 31 + 31 + 30&lt;br /&gt;
    ElseIf themonth = 11 Then ' NOVEMBER&lt;br /&gt;
      julianday = theday + 31 + 28 + leapyear + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31&lt;br /&gt;
    ElseIf themonth = 12 Then ' DECEMBER&lt;br /&gt;
      julianday = theday + 31 + 28 + leapyear + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30&lt;br /&gt;
    End If&lt;br /&gt;
    &lt;br /&gt;
    '' If we need decimal days then add the decimal part here.&lt;br /&gt;
    If decimalday = True Then&lt;br /&gt;
      julianday = julianday + thehour / 24 + theminute / 24 / 60&lt;br /&gt;
    End If&lt;br /&gt;
    &lt;br /&gt;
    '' ready to output back to the original spreadsheet.&lt;br /&gt;
    Worksheets(Worksheetz).Cells(row, outcol).Value = julianday&lt;br /&gt;
    &lt;br /&gt;
    '' Go to the next row.&lt;br /&gt;
    row = row + 1&lt;br /&gt;
  Loop&lt;br /&gt;
  Range(&amp;quot;A&amp;quot; &amp;amp; CStr(startrow)).Select&lt;br /&gt;
   &lt;br /&gt;
   &lt;br /&gt;
 End Sub&lt;/div&gt;</summary>
		<author><name>imported&gt;Bob</name></author>
		
	</entry>
</feed>