472,372 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,372 software developers and data experts.

How can I convert Julian Date to Calendar Date

I'm trying to convert a Julian Date (Format "4365") into an actual calendar
date in Visual Basic, can anyone help me out with this.
Jul 21 '05 #1
5 16081
I don't know what format 4365 is, but if you're talking about real Julian
dates (days and fractional days since noon Universal Time on January 1, 4713
BCE) I have some VB code that will do the two-way conversions between true
Julian and Gregorian calendars. I'd be happy to send it along to you if
that's what you're after.

Tom Dacon
Dacon Software Consulting

"goochey" <go*****@discussions.microsoft.com> wrote in message
news:11**********************************@microsof t.com...
I'm trying to convert a Julian Date (Format "4365") into an actual
calendar
date in Visual Basic, can anyone help me out with this.

Jul 21 '05 #2
Tom:
The 4 in 4365 stands for the year, and the 365 is the day number of that
year in this example it would be December 30, of 2004. I was hoping there
would be a function in VB that handled it, I think you code may be useful or
if you know of a VB built in function that would be great too.

"Tom Dacon" wrote:
I don't know what format 4365 is, but if you're talking about real Julian
dates (days and fractional days since noon Universal Time on January 1, 4713
BCE) I have some VB code that will do the two-way conversions between true
Julian and Gregorian calendars. I'd be happy to send it along to you if
that's what you're after.

Tom Dacon
Dacon Software Consulting

"goochey" <go*****@discussions.microsoft.com> wrote in message
news:11**********************************@microsof t.com...
I'm trying to convert a Julian Date (Format "4365") into an actual
calendar
date in Visual Basic, can anyone help me out with this.


Jul 21 '05 #3
That date format sound something like what used to be called 'manufacturing
date' in aerospace. In that format your "4365" would be "04365". VB has no
built-in functionality for date formats like that; you'll have to roll your
own unless someone else has already done so. Here's a quick-and-dirty
example of one way to solve it:

' Receives a date as a string in format "YDDD", where Y is the last digit
' of the year, and DDD is the day number within the year;
' e.g., "4365" is December 31, 2004.
Public Function ToDateTime(ByVal theDate As String) As DateTime
' A DateTime as of the first day of the specified year
Dim dt as new DateTime(CInt("200" + theDate.Substring(0, 1)), 1, 1)
' Add the specified number of days and return the resulting DateTime
object.
return dt.AddDays(CInt(theDate.Substring(1, 3)))
End Function

HTH,
Tom Dacon
Dacon Software Consulting
"goochey" <go*****@discussions.microsoft.com> wrote in message
news:6B**********************************@microsof t.com...
Tom:
The 4 in 4365 stands for the year, and the 365 is the day number of that
year in this example it would be December 30, of 2004. I was hoping there
would be a function in VB that handled it, I think you code may be useful
or
if you know of a VB built in function that would be great too.

"Tom Dacon" wrote:
I don't know what format 4365 is, but if you're talking about real Julian
dates (days and fractional days since noon Universal Time on January 1,
4713
BCE) I have some VB code that will do the two-way conversions between
true
Julian and Gregorian calendars. I'd be happy to send it along to you if
that's what you're after.

Tom Dacon
Dacon Software Consulting

"goochey" <go*****@discussions.microsoft.com> wrote in message
news:11**********************************@microsof t.com...
> I'm trying to convert a Julian Date (Format "4365") into an actual
> calendar
> date in Visual Basic, can anyone help me out with this.


Jul 21 '05 #4
Oops. There was a bug in the version I first posted, and the date came out
one day too high.
Try this instead:

' Receives a date as a string in format "YDDD", where Y is the last digit
' of the year, and DDD is the day number within the year; returns a
DateTime
' object with specified date. E.g., "4365" is December 31, 2004.
Public Function ToDateTime(ByVal theDate As String) As DateTime
' A DateTime as of the first day of the specified year
Dim dt as new DateTime(CInt("200" + theDate.Substring(0, 1)), 1, 1)
' Add the specified number of days and return the resulting DateTime
object.
return dt.AddDays(CInt(theDate.Substring(1, 3)) - 1)
End Function

This assumes leading zeroes in the day part of the date string. For
instance, January 1, 2004 would be "4001".

Sorry 'bout that.
Tom

"Tom Dacon" <td****@community.nospam> wrote in message
news:eo**************@TK2MSFTNGP15.phx.gbl...
That date format sound something like what used to be called
'manufacturing date' in aerospace. In that format your "4365" would be
"04365". VB has no built-in functionality for date formats like that;
you'll have to roll your own unless someone else has already done so.
Here's a quick-and-dirty example of one way to solve it:

' Receives a date as a string in format "YDDD", where Y is the last
digit
' of the year, and DDD is the day number within the year;
' e.g., "4365" is December 31, 2004.
Public Function ToDateTime(ByVal theDate As String) As DateTime
' A DateTime as of the first day of the specified year
Dim dt as new DateTime(CInt("200" + theDate.Substring(0, 1)), 1, 1)
' Add the specified number of days and return the resulting DateTime
object.
return dt.AddDays(CInt(theDate.Substring(1, 3)))
End Function

HTH,
Tom Dacon
Dacon Software Consulting
"goochey" <go*****@discussions.microsoft.com> wrote in message
news:6B**********************************@microsof t.com...
Tom:
The 4 in 4365 stands for the year, and the 365 is the day number of that
year in this example it would be December 30, of 2004. I was hoping
there
would be a function in VB that handled it, I think you code may be useful
or
if you know of a VB built in function that would be great too.

"Tom Dacon" wrote:
I don't know what format 4365 is, but if you're talking about real
Julian
dates (days and fractional days since noon Universal Time on January 1,
4713
BCE) I have some VB code that will do the two-way conversions between
true
Julian and Gregorian calendars. I'd be happy to send it along to you if
that's what you're after.

Tom Dacon
Dacon Software Consulting

"goochey" <go*****@discussions.microsoft.com> wrote in message
news:11**********************************@microsof t.com...
> I'm trying to convert a Julian Date (Format "4365") into an actual
> calendar
> date in Visual Basic, can anyone help me out with this.


Jul 21 '05 #5
Tom:
Thank you very much for your help, that problem was whipping me pretty good.

"Tom Dacon" wrote:
Oops. There was a bug in the version I first posted, and the date came out
one day too high.
Try this instead:

' Receives a date as a string in format "YDDD", where Y is the last digit
' of the year, and DDD is the day number within the year; returns a
DateTime
' object with specified date. E.g., "4365" is December 31, 2004.
Public Function ToDateTime(ByVal theDate As String) As DateTime
' A DateTime as of the first day of the specified year
Dim dt as new DateTime(CInt("200" + theDate.Substring(0, 1)), 1, 1)
' Add the specified number of days and return the resulting DateTime
object.
return dt.AddDays(CInt(theDate.Substring(1, 3)) - 1)
End Function

This assumes leading zeroes in the day part of the date string. For
instance, January 1, 2004 would be "4001".

Sorry 'bout that.
Tom

"Tom Dacon" <td****@community.nospam> wrote in message
news:eo**************@TK2MSFTNGP15.phx.gbl...
That date format sound something like what used to be called
'manufacturing date' in aerospace. In that format your "4365" would be
"04365". VB has no built-in functionality for date formats like that;
you'll have to roll your own unless someone else has already done so.
Here's a quick-and-dirty example of one way to solve it:

' Receives a date as a string in format "YDDD", where Y is the last
digit
' of the year, and DDD is the day number within the year;
' e.g., "4365" is December 31, 2004.
Public Function ToDateTime(ByVal theDate As String) As DateTime
' A DateTime as of the first day of the specified year
Dim dt as new DateTime(CInt("200" + theDate.Substring(0, 1)), 1, 1)
' Add the specified number of days and return the resulting DateTime
object.
return dt.AddDays(CInt(theDate.Substring(1, 3)))
End Function

HTH,
Tom Dacon
Dacon Software Consulting
"goochey" <go*****@discussions.microsoft.com> wrote in message
news:6B**********************************@microsof t.com...
Tom:
The 4 in 4365 stands for the year, and the 365 is the day number of that
year in this example it would be December 30, of 2004. I was hoping
there
would be a function in VB that handled it, I think you code may be useful
or
if you know of a VB built in function that would be great too.

"Tom Dacon" wrote:

I don't know what format 4365 is, but if you're talking about real
Julian
dates (days and fractional days since noon Universal Time on January 1,
4713
BCE) I have some VB code that will do the two-way conversions between
true
Julian and Gregorian calendars. I'd be happy to send it along to you if
that's what you're after.

Tom Dacon
Dacon Software Consulting

"goochey" <go*****@discussions.microsoft.com> wrote in message
news:11**********************************@microsof t.com...
> I'm trying to convert a Julian Date (Format "4365") into an actual
> calendar
> date in Visual Basic, can anyone help me out with this.



Jul 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: cg_news | last post by:
In short, what I am trying to do is, based on a date, calculate the week of year (as described in ISO 8601), then calculate the first and last date in this week period and return them in the format...
1
by: Raja | last post by:
Hi Anyone has any idea of how to convert Julian Date (eg. 12744057862..) to a VB.NET date time. Thanks in advance.
1
by: Sam | last post by:
How do I convert Julian Date to Calendar Date in ASP.Net 1.1 based on following guideline found at Internet? To convert Julian date to Gregorian date: double JD = 2299160.5; double Z =...
5
by: goochey | last post by:
I'm trying to convert a Julian Date (Format "4365") into an actual calendar date in Visual Basic, can anyone help me out with this.
4
by: Marcus | last post by:
Hi, I'm looking for useful starting points, suggestions, and sample code, to implement a calendar iterator. Simply, the iterator is seeded with an initial calendar date, e.g., "03-12-2006", and...
7
by: mesubham | last post by:
In VB toolbox, I put a window calendar, I have also put a textbox beside calendar. What is the code of VB6, when I click on calendar date, it will transfer to the textbox in dd/mm/yyyy format?
15
by: toadmaster | last post by:
I am new to access and I am learning as I go along; I am attempting to convert Julian dates to regular dates "MM-DD-YY"; I have tried the code below in the Query screen under criteria. ...
1
by: smdmca | last post by:
I have Julian date, I want to convert it into date. Is there any function in MySql to convert Julian date to date eg- Julian Date- 2455116 Date - Oct - 12, 2009
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.