Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I extract the DATETIME from a COleDateTime
Message
 
À
29/01/2001 19:45:26
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00470010
Message ID:
00470015
Vues:
36
Hi Bernard,

You could use:
lnTimeNumber = 36921.4494675926
ldDate = {^1899-12-30} + int(lnTimeNumber)
? ldDate    && prints 30-Jan-2001 (in current SET DATE format)
ltDateTime = dtot(ldDate) + (lnTimeNumber - int(lnTimeNumber)) * 24 * 60 * 60
? ltDateTime   && prints 30-Jan-2001 10:47:14
Cheers,

Andrew

>When communicating with a C++ COM server it returns the datetime as a cOleDateTime number eg:
>36921.4494675926
>
>The MSDN help says that this is in the format as :
>30 DEC 1899, Midnight = 0.00
>1 Jan 1900, midnight = 2.00
>
>"Where the DATE type is implemented using an 8 byte floating point number. Days are represented by whole number increments starting with 30 Dec 1899, midnight as time zero. Hour values are expressed as the absolute value of the fractional part of the number."
>
>So the number 36921.4494675976 translates roughly to 30 Jan 2001, 10:30 hours.
>
>My question is if such a number is received from the COM how do I convert it to a VFP DATETIME()?
>
>Any help will be greatly appreciated. Thanks.
>
>Bernard


If we were to introduce Visual FoxBase+, would we be able to work from the dotNet Prompt?


From Top 22 Developer Responses to defects in Software
2. "It’s not a bug, it’s a feature."
1. "I thought I fixed that."


All my FoxTalk and other articles are available on my web site.


Unless specifically identified otherwise, anthing posted here is purely my opinion and may or may not reflect the policies or practices of Microsoft.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform