ToOADate method

R

RobertM

Hi

I need to convert date values in double. I have noticed that the CF 1
doesn't support the ToOADate method.
any idea to do this by code (vs2003 + vb.net + CF1.1)

regards
 
S

Sergey Bogdanov

You can use .Ticks to get long instead of double. If you really want to
get double here you are an example:

DateTime t = DateTime.Now;
double r = TicksToOADate(t.Ticks)

....

private static double TicksToOADate(long value)
{
if (value == 0) return 0;
if (value < 0xc92a69c000)
{
value += 0x85103c0cb83c000;
}

if (value < 0x6efdddaec64000) throw new OverflowException();

long l = (value - 0x85103c0cb83c000) / ((long) 0x2710);
if (l < 0)
{
long t = l % ((long) 0x5265c00);
if (t != 0) l -= (0x5265c00 + t) * 2;
}
return ((double)l) / 86400000;
}


FYI, CF2.0 already supports ToOADate().
 
R

RobertM

Hi Sergey

thanks a lot but i don't understand C# code
any clue with vb code ?

regards

Sergey Bogdanov said:
You can use .Ticks to get long instead of double. If you really want to
get double here you are an example:

DateTime t = DateTime.Now;
double r = TicksToOADate(t.Ticks)

...

private static double TicksToOADate(long value)
{
if (value == 0) return 0;
if (value < 0xc92a69c000)
{
value += 0x85103c0cb83c000;
}

if (value < 0x6efdddaec64000) throw new OverflowException();

long l = (value - 0x85103c0cb83c000) / ((long) 0x2710);
if (l < 0)
{
long t = l % ((long) 0x5265c00);
if (t != 0) l -= (0x5265c00 + t) * 2;
}
return ((double)l) / 86400000;
}


FYI, CF2.0 already supports ToOADate().

--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com

Hi

I need to convert date values in double. I have noticed that the CF 1
doesn't support the ToOADate method.
any idea to do this by code (vs2003 + vb.net + CF1.1)

regards
 
G

Guest

http://www.danielmoth.com/Blog/2005/03/please-read-before-posting-to-ng.html

See point #11

-Chris


RobertM said:
Hi Sergey

thanks a lot but i don't understand C# code
any clue with vb code ?

regards

Sergey Bogdanov said:
You can use .Ticks to get long instead of double. If you really want to
get double here you are an example:

DateTime t = DateTime.Now;
double r = TicksToOADate(t.Ticks)

...

private static double TicksToOADate(long value)
{
if (value == 0) return 0;
if (value < 0xc92a69c000)
{
value += 0x85103c0cb83c000;
}

if (value < 0x6efdddaec64000) throw new OverflowException();

long l = (value - 0x85103c0cb83c000) / ((long) 0x2710);
if (l < 0)
{
long t = l % ((long) 0x5265c00);
if (t != 0) l -= (0x5265c00 + t) * 2;
}
return ((double)l) / 86400000;
}


FYI, CF2.0 already supports ToOADate().

--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com

Hi

I need to convert date values in double. I have noticed that the CF 1
doesn't support the ToOADate method.
any idea to do this by code (vs2003 + vb.net + CF1.1)

regards
 
S

Sergey Bogdanov

.... and one of C#=>VB.NET translators can be found here:
http://csharpconverter.claritycon.com/Default.aspx


--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com

Hi Sergey

thanks a lot but i don't understand C# code
any clue with vb code ?

regards

Sergey Bogdanov said:
You can use .Ticks to get long instead of double. If you really want to
get double here you are an example:

DateTime t = DateTime.Now;
double r = TicksToOADate(t.Ticks)

...

private static double TicksToOADate(long value)
{
if (value == 0) return 0;
if (value < 0xc92a69c000)
{
value += 0x85103c0cb83c000;
}

if (value < 0x6efdddaec64000) throw new OverflowException();

long l = (value - 0x85103c0cb83c000) / ((long) 0x2710);
if (l < 0)
{
long t = l % ((long) 0x5265c00);
if (t != 0) l -= (0x5265c00 + t) * 2;
}
return ((double)l) / 86400000;
}


FYI, CF2.0 already supports ToOADate().

--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com

Hi

I need to convert date values in double. I have noticed that the CF 1
doesn't support the ToOADate method.
any idea to do this by code (vs2003 + vb.net + CF1.1)

regards
 
R

RobertM

thanks a lot

Sergey Bogdanov said:
... and one of C#=>VB.NET translators can be found here:
http://csharpconverter.claritycon.com/Default.aspx


--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com

Hi Sergey

thanks a lot but i don't understand C# code
any clue with vb code ?

regards

Sergey Bogdanov said:
You can use .Ticks to get long instead of double. If you really want to
get double here you are an example:

DateTime t = DateTime.Now;
double r = TicksToOADate(t.Ticks)

...

private static double TicksToOADate(long value)
{
if (value == 0) return 0;
if (value < 0xc92a69c000)
{
value += 0x85103c0cb83c000;
}

if (value < 0x6efdddaec64000) throw new OverflowException();

long l = (value - 0x85103c0cb83c000) / ((long) 0x2710);
if (l < 0)
{
long t = l % ((long) 0x5265c00);
if (t != 0) l -= (0x5265c00 + t) * 2;
}
return ((double)l) / 86400000;
}


FYI, CF2.0 already supports ToOADate().

--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com


RobertM wrote:
Hi

I need to convert date values in double. I have noticed that the CF 1
doesn't support the ToOADate method.
any idea to do this by code (vs2003 + vb.net + CF1.1)

regards
 
R

RobertM

what's wrong with you ?

http://www.danielmoth.com/Blog/2005/03/please-read-before-posting-to-ng.html

See point #11

-Chris


RobertM said:
Hi Sergey

thanks a lot but i don't understand C# code
any clue with vb code ?

regards

Sergey Bogdanov said:
You can use .Ticks to get long instead of double. If you really want to
get double here you are an example:

DateTime t = DateTime.Now;
double r = TicksToOADate(t.Ticks)

...

private static double TicksToOADate(long value)
{
if (value == 0) return 0;
if (value < 0xc92a69c000)
{
value += 0x85103c0cb83c000;
}

if (value < 0x6efdddaec64000) throw new OverflowException();

long l = (value - 0x85103c0cb83c000) / ((long) 0x2710);
if (l < 0)
{
long t = l % ((long) 0x5265c00);
if (t != 0) l -= (0x5265c00 + t) * 2;
}
return ((double)l) / 86400000;
}


FYI, CF2.0 already supports ToOADate().

--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com


RobertM wrote:
Hi

I need to convert date values in double. I have noticed that the CF 1
doesn't support the ToOADate method.
any idea to do this by code (vs2003 + vb.net + CF1.1)

regards
 
C

Chris Tacke, MVP

I'm pointing out that the solution was given. Asking for someone to rewrite
what is essentially math, and not at all complex is a bit much. He gave you
the solution, the least you could do is make the effort to convert it to VB,
then if you have trouble with some part of the conversion come back and ask
about it.

The shocker of doing that is that you might actually learn how it works,
rather than exercising your cut and paste skills.

-Chris


RobertM said:
what's wrong with you ?

http://www.danielmoth.com/Blog/2005/03/please-read-before-posting-to-ng.html

See point #11

-Chris


RobertM said:
Hi Sergey

thanks a lot but i don't understand C# code
any clue with vb code ?

regards

"Sergey Bogdanov" <[email protected]> a ecrit dans le message de
news: (e-mail address removed)...
You can use .Ticks to get long instead of double. If you really want to
get double here you are an example:

DateTime t = DateTime.Now;
double r = TicksToOADate(t.Ticks)

...

private static double TicksToOADate(long value)
{
if (value == 0) return 0;
if (value < 0xc92a69c000)
{
value += 0x85103c0cb83c000;
}

if (value < 0x6efdddaec64000) throw new OverflowException();

long l = (value - 0x85103c0cb83c000) / ((long) 0x2710);
if (l < 0)
{
long t = l % ((long) 0x5265c00);
if (t != 0) l -= (0x5265c00 + t) * 2;
}
return ((double)l) / 86400000;
}


FYI, CF2.0 already supports ToOADate().

--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com


RobertM wrote:
Hi

I need to convert date values in double. I have noticed that the CF 1
doesn't support the ToOADate method.
any idea to do this by code (vs2003 + vb.net + CF1.1)

regards
 
C

Chris Tacke, MVP

This is also helpful for those wanting to do the VB->C# conversion

http://www.danielmoth.com/Blog/2005/03/using-c-from-vb-level-000.html

-Chris

RobertM said:
what's wrong with you ?

http://www.danielmoth.com/Blog/2005/03/please-read-before-posting-to-ng.html

See point #11

-Chris


RobertM said:
Hi Sergey

thanks a lot but i don't understand C# code
any clue with vb code ?

regards

"Sergey Bogdanov" <[email protected]> a ecrit dans le message de
news: (e-mail address removed)...
You can use .Ticks to get long instead of double. If you really want to
get double here you are an example:

DateTime t = DateTime.Now;
double r = TicksToOADate(t.Ticks)

...

private static double TicksToOADate(long value)
{
if (value == 0) return 0;
if (value < 0xc92a69c000)
{
value += 0x85103c0cb83c000;
}

if (value < 0x6efdddaec64000) throw new OverflowException();

long l = (value - 0x85103c0cb83c000) / ((long) 0x2710);
if (l < 0)
{
long t = l % ((long) 0x5265c00);
if (t != 0) l -= (0x5265c00 + t) * 2;
}
return ((double)l) / 86400000;
}


FYI, CF2.0 already supports ToOADate().

--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com


RobertM wrote:
Hi

I need to convert date values in double. I have noticed that the CF 1
doesn't support the ToOADate method.
any idea to do this by code (vs2003 + vb.net + CF1.1)

regards
 
R

RobertM

you use math !!!!!!!!!!!!!
i.e. something that someone else wrote
.... you lazy guy


Chris Tacke said:
I'm pointing out that the solution was given. Asking for someone to
rewrite what is essentially math, and not at all complex is a bit much.
He gave you the solution, the least you could do is make the effort to
convert it to VB, then if you have trouble with some part of the
conversion come back and ask about it.

The shocker of doing that is that you might actually learn how it works,
rather than exercising your cut and paste skills.

-Chris


RobertM said:
what's wrong with you ?

http://www.danielmoth.com/Blog/2005/03/please-read-before-posting-to-ng.html

See point #11

-Chris


"RobertM" <f> wrote in message
Hi Sergey

thanks a lot but i don't understand C# code
any clue with vb code ?

regards

"Sergey Bogdanov" <[email protected]> a ecrit dans le message
de news: (e-mail address removed)...
You can use .Ticks to get long instead of double. If you really want
to get double here you are an example:

DateTime t = DateTime.Now;
double r = TicksToOADate(t.Ticks)

...

private static double TicksToOADate(long value)
{
if (value == 0) return 0;
if (value < 0xc92a69c000)
{
value += 0x85103c0cb83c000;
}

if (value < 0x6efdddaec64000) throw new OverflowException();

long l = (value - 0x85103c0cb83c000) / ((long) 0x2710);
if (l < 0)
{
long t = l % ((long) 0x5265c00);
if (t != 0) l -= (0x5265c00 + t) * 2;
}
return ((double)l) / 86400000;
}


FYI, CF2.0 already supports ToOADate().

--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com


RobertM wrote:
Hi

I need to convert date values in double. I have noticed that the CF 1
doesn't support the ToOADate method.
any idea to do this by code (vs2003 + vb.net + CF1.1)

regards
 
P

Paul G. Tobey [eMVP]

OK, so you're trying to make sure that you never get any help in the future?
You, not Chris, are the new one here. If you want to walk into a room and
immediately try to make sure that everyone hates you, you are obviously on
the right track...

Paul T.

RobertM said:
you use math !!!!!!!!!!!!!
i.e. something that someone else wrote
... you lazy guy


Chris Tacke said:
I'm pointing out that the solution was given. Asking for someone to
rewrite what is essentially math, and not at all complex is a bit much.
He gave you the solution, the least you could do is make the effort to
convert it to VB, then if you have trouble with some part of the
conversion come back and ask about it.

The shocker of doing that is that you might actually learn how it works,
rather than exercising your cut and paste skills.

-Chris


RobertM said:
what's wrong with you ?

"<ctacke/>" <ctacke_AT_OpenNETCF_com> a écrit dans le message de (e-mail address removed)...
http://www.danielmoth.com/Blog/2005/03/please-read-before-posting-to-ng.html

See point #11

-Chris


"RobertM" <f> wrote in message
Hi Sergey

thanks a lot but i don't understand C# code
any clue with vb code ?

regards

"Sergey Bogdanov" <[email protected]> a ecrit dans le message
de news: (e-mail address removed)...
You can use .Ticks to get long instead of double. If you really want
to get double here you are an example:

DateTime t = DateTime.Now;
double r = TicksToOADate(t.Ticks)

...

private static double TicksToOADate(long value)
{
if (value == 0) return 0;
if (value < 0xc92a69c000)
{
value += 0x85103c0cb83c000;
}

if (value < 0x6efdddaec64000) throw new OverflowException();

long l = (value - 0x85103c0cb83c000) / ((long) 0x2710);
if (l < 0)
{
long t = l % ((long) 0x5265c00);
if (t != 0) l -= (0x5265c00 + t) * 2;
}
return ((double)l) / 86400000;
}


FYI, CF2.0 already supports ToOADate().

--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com


RobertM wrote:
Hi

I need to convert date values in double. I have noticed that the CF
1 doesn't support the ToOADate method.
any idea to do this by code (vs2003 + vb.net + CF1.1)

regards
 
R

RobertM

precisely!!!! i 'm a newbie
when I made a research in this forum with 'ToOADate' I didn't find any
answer
then which is the interest to say to me that I should seek better than ask
or do some math
if I come in a forum is precisely to find some assistance and not to be
said that I do not do it
it is ridiculous and counters the concept even of this forum

Paul G. Tobey said:
OK, so you're trying to make sure that you never get any help in the
future? You, not Chris, are the new one here. If you want to walk into a
room and immediately try to make sure that everyone hates you, you are
obviously on the right track...

Paul T.

RobertM said:
you use math !!!!!!!!!!!!!
i.e. something that someone else wrote
... you lazy guy


Chris Tacke said:
I'm pointing out that the solution was given. Asking for someone to
rewrite what is essentially math, and not at all complex is a bit much.
He gave you the solution, the least you could do is make the effort to
convert it to VB, then if you have trouble with some part of the
conversion come back and ask about it.

The shocker of doing that is that you might actually learn how it works,
rather than exercising your cut and paste skills.

-Chris


"RobertM" <f> wrote in message
what's wrong with you ?

"<ctacke/>" <ctacke_AT_OpenNETCF_com> a écrit dans le message de (e-mail address removed)...
http://www.danielmoth.com/Blog/2005/03/please-read-before-posting-to-ng.html

See point #11

-Chris


"RobertM" <f> wrote in message
Hi Sergey

thanks a lot but i don't understand C# code
any clue with vb code ?

regards

"Sergey Bogdanov" <[email protected]> a ecrit dans le message
de news: (e-mail address removed)...
You can use .Ticks to get long instead of double. If you really want
to get double here you are an example:

DateTime t = DateTime.Now;
double r = TicksToOADate(t.Ticks)

...

private static double TicksToOADate(long value)
{
if (value == 0) return 0;
if (value < 0xc92a69c000)
{
value += 0x85103c0cb83c000;
}

if (value < 0x6efdddaec64000) throw new OverflowException();

long l = (value - 0x85103c0cb83c000) / ((long) 0x2710);
if (l < 0)
{
long t = l % ((long) 0x5265c00);
if (t != 0) l -= (0x5265c00 + t) * 2;
}
return ((double)l) / 86400000;
}


FYI, CF2.0 already supports ToOADate().

--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com


RobertM wrote:
Hi

I need to convert date values in double. I have noticed that the CF
1 doesn't support the ToOADate method.
any idea to do this by code (vs2003 + vb.net + CF1.1)

regards
 
P

Paul G. Tobey [eMVP]

The concept is to provide peer-to-peer support for software guys having
problems with .NET CF. Since .NET is a multi-language environment, we
expect you to take the initiative and, if we have code and post it for you
in C#, do the conversion yourself. It's not like Sergey's fix required you
to port several classes and two hundred lines of code, or even to look up
obscure syntax for, say, P/Invoking something written in native code.

You just come across as "I'm a poor VB.NET programmer. Please write my code
for me." I don't care what forum you post in, you're going to get a
reaction from that. If you read the threads around yours in the history of
the group, you'll find that you are the exception, not the rule, so it's
reasonable to assume that the one unique variable in your thread, you, are
the source of the difference.

Paul T.

RobertM said:
precisely!!!! i 'm a newbie
when I made a research in this forum with 'ToOADate' I didn't find any
answer
then which is the interest to say to me that I should seek better than ask
or do some math
if I come in a forum is precisely to find some assistance and not to be
said that I do not do it
it is ridiculous and counters the concept even of this forum

Paul G. Tobey said:
OK, so you're trying to make sure that you never get any help in the
future? You, not Chris, are the new one here. If you want to walk into a
room and immediately try to make sure that everyone hates you, you are
obviously on the right track...

Paul T.

RobertM said:
you use math !!!!!!!!!!!!!
i.e. something that someone else wrote
... you lazy guy


"Chris Tacke, MVP" <[email protected]> a écrit dans le
message de news: (e-mail address removed)...

I'm pointing out that the solution was given. Asking for someone to
rewrite what is essentially math, and not at all complex is a bit much.
He gave you the solution, the least you could do is make the effort to
convert it to VB, then if you have trouble with some part of the
conversion come back and ask about it.

The shocker of doing that is that you might actually learn how it
works, rather than exercising your cut and paste skills.

-Chris


"RobertM" <f> wrote in message
what's wrong with you ?

"<ctacke/>" <ctacke_AT_OpenNETCF_com> a écrit dans le message de (e-mail address removed)...
http://www.danielmoth.com/Blog/2005/03/please-read-before-posting-to-ng.html

See point #11

-Chris


"RobertM" <f> wrote in message
Hi Sergey

thanks a lot but i don't understand C# code
any clue with vb code ?

regards

"Sergey Bogdanov" <[email protected]> a ecrit dans le
message de news: (e-mail address removed)...
You can use .Ticks to get long instead of double. If you really
want to get double here you are an example:

DateTime t = DateTime.Now;
double r = TicksToOADate(t.Ticks)

...

private static double TicksToOADate(long value)
{
if (value == 0) return 0;
if (value < 0xc92a69c000)
{
value += 0x85103c0cb83c000;
}

if (value < 0x6efdddaec64000) throw new OverflowException();

long l = (value - 0x85103c0cb83c000) / ((long) 0x2710);
if (l < 0)
{
long t = l % ((long) 0x5265c00);
if (t != 0) l -= (0x5265c00 + t) * 2;
}
return ((double)l) / 86400000;
}


FYI, CF2.0 already supports ToOADate().

--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com


RobertM wrote:
Hi

I need to convert date values in double. I have noticed that the
CF 1 doesn't support the ToOADate method.
any idea to do this by code (vs2003 + vb.net + CF1.1)

regards
 
D

Daniel Moth

when I made a research in this forum with 'ToOADate' I didn't find any
Where did you search? Searching this ng gives you this:
http://groups.google.com/group/micr...7f4d06f558?q=tooadate&rnum=3#c02e027f4d06f558
....which leads you to this (in VB no less):
http://www.opennetcf.org/Forums/topic.asp?TOPIC_ID=47

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


RobertM said:
precisely!!!! i 'm a newbie
when I made a research in this forum with 'ToOADate' I didn't find any
answer
then which is the interest to say to me that I should seek better than ask
or do some math
if I come in a forum is precisely to find some assistance and not to be
said that I do not do it
it is ridiculous and counters the concept even of this forum

Paul G. Tobey said:
OK, so you're trying to make sure that you never get any help in the
future? You, not Chris, are the new one here. If you want to walk into a
room and immediately try to make sure that everyone hates you, you are
obviously on the right track...

Paul T.

RobertM said:
you use math !!!!!!!!!!!!!
i.e. something that someone else wrote
... you lazy guy


"Chris Tacke, MVP" <[email protected]> a écrit dans le
message de news: (e-mail address removed)...

I'm pointing out that the solution was given. Asking for someone to
rewrite what is essentially math, and not at all complex is a bit much.
He gave you the solution, the least you could do is make the effort to
convert it to VB, then if you have trouble with some part of the
conversion come back and ask about it.

The shocker of doing that is that you might actually learn how it
works, rather than exercising your cut and paste skills.

-Chris


"RobertM" <f> wrote in message
what's wrong with you ?

"<ctacke/>" <ctacke_AT_OpenNETCF_com> a écrit dans le message de (e-mail address removed)...
http://www.danielmoth.com/Blog/2005/03/please-read-before-posting-to-ng.html

See point #11

-Chris


"RobertM" <f> wrote in message
Hi Sergey

thanks a lot but i don't understand C# code
any clue with vb code ?

regards

"Sergey Bogdanov" <[email protected]> a ecrit dans le
message de news: (e-mail address removed)...
You can use .Ticks to get long instead of double. If you really
want to get double here you are an example:

DateTime t = DateTime.Now;
double r = TicksToOADate(t.Ticks)

...

private static double TicksToOADate(long value)
{
if (value == 0) return 0;
if (value < 0xc92a69c000)
{
value += 0x85103c0cb83c000;
}

if (value < 0x6efdddaec64000) throw new OverflowException();

long l = (value - 0x85103c0cb83c000) / ((long) 0x2710);
if (l < 0)
{
long t = l % ((long) 0x5265c00);
if (t != 0) l -= (0x5265c00 + t) * 2;
}
return ((double)l) / 86400000;
}


FYI, CF2.0 already supports ToOADate().

--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com


RobertM wrote:
Hi

I need to convert date values in double. I have noticed that the
CF 1 doesn't support the ToOADate method.
any idea to do this by code (vs2003 + vb.net + CF1.1)

regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top