Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Storing a date into its simplest format
Message
From
30/01/2008 17:45:24
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
 
 
To
30/01/2008 17:36:34
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01287307
Message ID:
01287330
Views:
7
>>myDate.AddSeconds(i)
>
>I need some adjustments here based on that approach. Do you see what is wrong?
>
>
>        Dim lnDateAsTicks As Double = 0
>        Dim ldNewDate As Date
>        Dim ldDate As Date = Date.Now
>        MessageBox.Show(ldDate.ToString)
>        lnDateAsTicks = ldDate.Ticks
>        ldNewDate.AddSeconds(lnDateAsTicks)
>        MessageBox.Show(ldNewDate.ToString)
>
>
>I can get the lnDateAsTicks. But, when I try to add that number of ticks to an empty date value, I end up with an error.

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.
Very fitting: http://xkcd.com/386/
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform