By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,658 Members | 1,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,658 IT Pros & Developers. It's quick & easy.

How can I convert Julian Date to Calendar Date

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.