Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Storing a date into its simplest format
Message
De
30/01/2008 18:23:10
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
 
À
30/01/2008 18:18:18
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01287307
Message ID:
01287349
Vues:
6
>>You have to add the ticks to an existing date. What are you using at your token date?
>>
>>Here is what I was thinking:
>>
>>        Dim tokenDate As Date = Date.Parse("1/1/1900")
>>        Dim result As Long
>>
>>        'This is the value you would want to store
>>        result = Date.Now.Subtract(tokenDate).TotalSeconds
>>
>>        'Convert the stored value back to a date
>>        MsgBox(tokenDate.AddSeconds(result))
>>
>>
>>Make sure you store your result as Long (Int64) otherwise you will get an overflow error.
>
>This is not working. The initial date I have is not always the same after the dual conversion. Sometimes, I have a difference of one second:
>
>
>        Dim lnResult As Long
>        Dim ldTokenDate As Date = Date.Parse("1/1/1900")
>        Dim ldDate As Date = Date.Now
>        Dim ldNewDate As Date = Date.Now
>        MessageBox.Show(ldDate.ToString)
>        lnResult = ldDate.Subtract(ldTokenDate).TotalSeconds
>        MessageBox.Show(lnResult.ToString)
>        ldNewDate = ldTokenDate.AddSeconds(lnResult)
>        MessageBox.Show(ldNewDate.ToString)
>
I wonder if it is rounding seconds.
Very fitting: http://xkcd.com/386/
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform