Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to covert Julian date to calendar date, Urgent !

georgewonggeorgewong Posts: 8Member
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

Comments

  • DrMartenDrMarten Posts: 748Member
    [b][red]This message was edited by DrMarten at 2006-6-6 3:19:12[/red][/b][hr]

    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 [b]inclusive[/b].
    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:>
    [code]
    Dim NoOfYears, remainingDays, newRemainingDays As Integer
    NoOfYears=38875365 '= NoOfYears to add to 1900.
    'Reverse slash or is integer division.

    remainingDays=38875 mod 365 '= remainingDays

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

    'I don't think INTEGER DIVISION rounds up.

    newRemainingDays=remainingDays-27[red]
    newRemainingDays=newRemainingDays-1[/red]

    'newRemainingDays =157 this is the day number in the year.
    [/code]


    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 ).



  • georgewonggeorgewong Posts: 8Member
    : [b][red]This message was edited by DrMarten at 2006-6-6 3:19:12[/red][/b][hr]
    :
    : 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 [b]inclusive[/b].
    : 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:>
    : [code]
    : Dim NoOfYears, remainingDays, newRemainingDays As Integer
    : NoOfYears=38875365 '= NoOfYears to add to 1900.
    : 'Reverse slash or is integer division.
    :
    : remainingDays=38875 mod 365 '= remainingDays
    :
    : 'Deduct leap years since 1900 including 1900 [b]inclusive
    : '...in other words.[/b]
    : [blue]'You can get the 27 by ((year-1900)4)+1
    : 'E.G. ((2006-1900)4)+1 = 27 [/blue][red]
    : 'You could add 2 instead to give the FINAL answer,
    : 'if you do then DELETE the RED line of code below.[/red]
    : 'What this will do is make the sum>>
    : '((2006-1900)4)+2 = 28
    :
    : 'I don't think INTEGER DIVISION rounds up.
    :
    : newRemainingDays=remainingDays-27[red]
    : newRemainingDays=newRemainingDays-1[/red]
    :
    : 'newRemainingDays =157 this is the day number in the year.
    : [/code]
    :
    :
    : 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

  • DrMartenDrMarten Posts: 748Member
    Hi George,

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


    Regards,

    Dr M.

  • georgewonggeorgewong Posts: 8Member
    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.
    :
    :

Sign In or Register to comment.