469,360 Members | 1,799 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,360 developers. It's quick & easy.

How to convert a DateTime to a long

Hi,

What is the easiest way to convert a DateTime object to a
long?? - And the other way back??
(For database use)

Regards,

Vicki

Nov 15 '05 #1
3 49558
DateTime dateTime = ....
long number = Convert.ToInt64( dateTime );
or
long number = dateTime.Ticks;

"Vicki Carlsen" <vc*@tricon.dk> ha scritto nel messaggio
news:09****************************@phx.gbl...
Hi,

What is the easiest way to convert a DateTime object to a
long?? - And the other way back??
(For database use)

Regards,

Vicki

Nov 15 '05 #2
Why not change the type in the database to DateTime?
"Christian" <pl***********************@novasoftware.it> wrote in message
news:ec**************@TK2MSFTNGP11.phx.gbl...
DateTime dateTime = ....
long number = Convert.ToInt64( dateTime );
or
long number = dateTime.Ticks;

"Vicki Carlsen" <vc*@tricon.dk> ha scritto nel messaggio
news:09****************************@phx.gbl...
Hi,

What is the easiest way to convert a DateTime object to a
long?? - And the other way back??
(For database use)

Regards,

Vicki


Nov 15 '05 #3
long number = Convert.ToInt64(dataTime), does not work.
But long numer = dateTime.Ticks, was all I needed to
know... Thanks :o)

Regards,

Vicki
-----Original Message-----
Why not change the type in the database to DateTime?
"Christian" <pl***********************@novasoftware.it> wrote in messagenews:ec**************@TK2MSFTNGP11.phx.gbl...
DateTime dateTime = ....
long number = Convert.ToInt64( dateTime );
or
long number = dateTime.Ticks;

"Vicki Carlsen" <vc*@tricon.dk> ha scritto nel messaggio
news:09****************************@phx.gbl...
> Hi,
>
> What is the easiest way to convert a DateTime object to a > long?? - And the other way back??
> (For database use)
>
> Regards,
>
> Vicki
>


.

Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Logan X via .NET 247 | last post: by
11 posts views Thread by jguilford | last post: by
3 posts views Thread by David | last post: by
17 posts views Thread by Terry Jolly | last post: by
4 posts views Thread by PeteOlcott | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.