VB.NET

Moderators: seancampbell
Number of threads: 4022
Number of posts: 10035

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How to covert Julian date to calendar date, Urgent ! Posted by georgewong on 6 Jun 2006 at 12:09 AM
Dear all Professional :
I got a string which contain a value of "38875" and I would like to convert this Julian Date into VB.Net Calendar date (2006/06/06) , please advise and give me some sample , tkx so much .....

eg dim tm_date as string = "38875"
how to convert into calendar date of VB.net .....

George

Report
1st Jan year 1900 is day zero nil or nought zilch or o. (Updated). Posted by DrMarten on 6 Jun 2006 at 2:49 AM
This message was edited by DrMarten at 2006-6-6 3:19:12


38875/365= 106.50684931 50684931 50684931 50684931

Take the integer 106 and add it onto 1900 gives 2006.

1900+106=2006

Take the remainder or MOD of 38875/365 = 185

i.e. 38875 mod 365 = 185

now subtract the number of leap years from 1900 till now inclusive.
This is 27 as 1900 was a leap year, as was 2000.

( I had heard if a year ends with just 2 noughts like 1900 it's not counted as a leap year<>somewhere? Not sure on that one :-| )

So getting back then...>

185-27=158.

Now from this we must subtract 1 as Jan 1st 1900 was day zero.

Microsoft like to start counting from zero for some functions ( but not all, some in VB.Net start at 1 ).

So 157 then is the 157th day of this year or 6/06/2006.

31 (Jan) + 28 (Feb) + 31 (March) + 30 (April) + 31 (May) + 6 = 157.


Summary:>
Dim NoOfYears, remainingDays, newRemainingDays As Integer
NoOfYears=38875\365 '= NoOfYears to add to 1900.
'Reverse slash or \ is integer division.

remainingDays=38875 mod 365 '= remainingDays

'Deduct leap years since 1900 including 1900 inclusive
'...in other words.
'You can get the 27 by ((year-1900)\4)+1 
'E.G. ((2006-1900)\4)+1 = 27 
'You could add 2 instead to give the FINAL answer,
'if you do then DELETE the RED line of code below.
'What this will do is make the sum>>
'((2006-1900)\4)+2 = 28 

'I don't think INTEGER DIVISION rounds up.

newRemainingDays=remainingDays-27
newRemainingDays=newRemainingDays-1

'newRemainingDays =157 this is the day number in the year.



Regards,

Dr M.

P.S. The Adjust time/date function on a PC goes up to 31/12/2099, i think most of dont want to live to see that day anyway ( we'll be too old or pushing up daisy's ).



Report
Re: 1st Jan year 1900 is day zero nil or nought zilch or o. (Updated). Posted by georgewong on 6 Jun 2006 at 8:53 PM
: This message was edited by DrMarten at 2006-6-6 3:19:12

:
: 38875/365= 106.50684931 50684931 50684931 50684931
:
: Take the integer 106 and add it onto 1900 gives 2006.
:
: 1900+106=2006
:
: Take the remainder or MOD of 38875/365 = 185
:
: i.e. 38875 mod 365 = 185
:
: now subtract the number of leap years from 1900 till now inclusive.
: This is 27 as 1900 was a leap year, as was 2000.
:
: ( I had heard if a year ends with just 2 noughts like 1900 it's not counted as a leap year<>somewhere? Not sure on that one :-| )
:
: So getting back then...>
:
: 185-27=158.
:
: Now from this we must subtract 1 as Jan 1st 1900 was day zero.
:
: Microsoft like to start counting from zero for some functions ( but not all, some in VB.Net start at 1 ).
:
: So 157 then is the 157th day of this year or 6/06/2006.
:
: 31 (Jan) + 28 (Feb) + 31 (March) + 30 (April) + 31 (May) + 6 = 157.
:
:
: Summary:>
:
: Dim NoOfYears, remainingDays, newRemainingDays As Integer
: NoOfYears=38875\365 '= NoOfYears to add to 1900.
: 'Reverse slash or \ is integer division.
: 
: remainingDays=38875 mod 365 '= remainingDays
: 
: 'Deduct leap years since 1900 including 1900 inclusive
: '...in other words.
: 'You can get the 27 by ((year-1900)\4)+1 
: 'E.G. ((2006-1900)\4)+1 = 27 
: 'You could add 2 instead to give the FINAL answer,
: 'if you do then DELETE the RED line of code below.
: 'What this will do is make the sum>>
: '((2006-1900)\4)+2 = 28 
: 
: 'I don't think INTEGER DIVISION rounds up.
: 
: newRemainingDays=remainingDays-27
: newRemainingDays=newRemainingDays-1
: 
: 'newRemainingDays =157 this is the day number in the year.
: 

:
:
: Regards,
:
: Dr M.
:
: P.S. The Adjust time/date function on a PC goes up to 31/12/2099, i think most of dont want to live to see that day anyway ( we'll be too old or pushing up daisy's ).
:
:
:
:
tkx a lots...

George

Report
From which function or program did you get the 38875 please? Posted by DrMarten on 8 Jun 2006 at 2:51 PM
Hi George,

From which function or program did you get the 38875 please?


Regards,

Dr M.

Report
Re: From which function or program did you get the 38875 please? Posted by georgewong on 9 Jun 2006 at 5:44 PM
Hello Dr. M.
The value of 38875 was came from 3rd party external program. But I found there was a function "datetime.fromOAdate" which can covert julian into Calendar date. Tkx a again for your assistance..

George



: Hi George,
:
: From which function or program did you get the 38875 please?
:
:
: Regards,
:
: Dr M.
:
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.