I know this is not a VB6.0 group but still Iam asking this question because
I didnt
get any proper reply in any other group..
The answer given to me for my first question
by Alexander Mueller and Dr John Stockton is really excellent...
So Iam really forced to post my second question here ....
Could any one here help me in converting a standard date and time to
Julian date (1970) using vb6.0?
For example, ( standard date ) 03/12/2001 = ( Converted Julian date ) 11659
Regards
Jack
Hi,
You should look into the DateAdd and DateDiff functions, used both in
VBScript and VB. Usually, julian dates are the number of days since the
beginning of the year. There is also a Julian date that is the number of
days since Jan. 1, 4713 BC. I would guess that your julian date has the zero
as 1/1/1970, but it doesn't add up.
dtmZero = #1/1/1970#
dtmValue = #3/12/2001#
lngDays = DateDiff("d", dtmZero, dtmValue)
Wscript.Echo CStr(lngDays)
results in 11393. In fact, using DateAdd, I find that 11659 days since
1/1/1970 is 12/3/2001. Maybe someone else knows better.
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
>Could any one here help me in converting a standard date and time to
>Julian date (1970) using vb6.0?
You ignored the bit about that not being a Julian Date.
>For example, ( standard date ) 03/12/2001 = ( Converted Julian date ) 11659
That's not a standard date; ISO 8601 for that is 2001-03-12. Yours is
an FFF date. Programming is much easier with rational date formats.
A Date as Y M D can be converted to a CDate by DateSerial(Y, M, D)
assuming Gregorian, independently of localisation.
A CDate D converts to a Long Integer by CLng(D).
D = DateSerial(2001, 3, 12)
D = CLng(D) - 25569 ' CLng(DateSerial(1970, 1, 1))
document.writeln D
will work in any location in VBScript; for a VB6.0 solution, translate
it or ask in a VB newsgroup. It is of course just the reverse of what
you were given before. DatePart etc. are not needed for straightforward
work.
Read <URL:http://www.merlyn.demon.co.uk/vb-dates.htm> ff.
To convert to a CJD, use the fact that 1995-10-10 was CMJD 50000, and
add 2400001 to get from CMJD to CJD. See sig below.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.