Avatar billede mh Nybegynder
18. januar 2000 - 13:43 Der er 3 kommentarer og
1 løsning

Converting a Date to an Integer

(Konvertering af dato til heltal).
I am aware that Microsoft has a conversion at least in Excel and
I believe all MS applications that will let me transfer a date into a number (i.e. 8/7/1999 is number 36379 and 8/8/1999 is 36380 etc.)
How can I set my program up to convert this date to a number? Or is there a 'secret' JavaScript function / method
somewhere...
(It is really needed to feed the right values to a complex COM-Obj.)

Looking forward to be hearing from you?! brgds.
Avatar billede reason Nybegynder
18. januar 2000 - 14:46 #1
U can use parseInt() like this :
var MyInt = parseInt(MyData)
Avatar billede mh Nybegynder
18. januar 2000 - 15:29 #2
The idea was ok - but I need to convert the date from a format dd/mm/yyyy to an Integer - not just the 'dd' part...

f.ex. I found that in a COleDateTime this is defined as:

The DATE type is implemented as a floating-point value, measuring days from midnight, 30 December 1899. So, midnight, 31 December 1899 is represented by 1.0. Similarly, 6 AM, 1 January 1900 is represented by 2.25, and midnight, 29 December 1899 is – 1.0. However, 6 AM, 29 December 1899 is – 1.25.

Note  To interpret the time portion, take the absolute value of the fractional part of the number.

The COleDateTime class handles dates from 1 January 100 – 31 December 9999.

Does a dual function in JavaScript to the COleDateTime in C++ exist?
Avatar billede olebole Juniormester
21. august 2000 - 00:58 #3
<ole>
I don\'t recall a JavaScript function to format time in that way, but if you can run ASP or PHP on your sever, you might be saved. PHP has a timestamp running from January 1. 1970 - so you would be able to simply once and for all calculate the number up til then and add to the timestamp. Then you could write in the HTML - or what ever.
/Vh
</bole>
Avatar billede olebole Juniormester
29. august 2000 - 13:09 #4
Try this in java script:

var str = Date.parse(\"Aug 29, 2000\");
alert(str);

Will alert the number af milliseconds from Jan. 1. 1970.
/Vh
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester

IT-JOB