473,503 Members | 12,003 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 16280
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
14860
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
4856
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
4526
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
797
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
2198
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
14789
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
16084
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
9739
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
7067
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6975
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5562
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4992
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
371
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.