PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework ToOADate method

Reply

ToOADate method

 
Thread Tools Rate Thread
Old 03-03-2006, 07:27 AM   #1
RobertM
Guest
 
Posts: n/a
Default ToOADate method


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


  Reply With Quote
Old 03-03-2006, 08:24 AM   #2
Sergey Bogdanov
Guest
 
Posts: n/a
Default Re: ToOADate method

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
>
>

  Reply With Quote
Old 03-03-2006, 09:10 AM   #3
RobertM
Guest
 
Posts: n/a
Default Re: ToOADate method

Hi Sergey

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

regards

"Sergey Bogdanov" <sergey.bogdanov@gmail.com> a ecrit dans le message de
news: u7TwwvpPGHA.564@TK2MSFTNGP12.phx.gbl...
> 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



  Reply With Quote
Old 03-03-2006, 11:21 AM   #4
Guest
 
Posts: n/a
Default Re: ToOADate method

http://www.danielmoth.com/Blog/2005...ting-to-ng.html

See point #11

-Chris


"RobertM" <f> wrote in message news:Ojt1GJqPGHA.5464@TK2MSFTNGP11.phx.gbl...
> Hi Sergey
>
> thanks a lot but i don't understand C# code
> any clue with vb code ?
>
> regards
>
> "Sergey Bogdanov" <sergey.bogdanov@gmail.com> a ecrit dans le message de
> news: u7TwwvpPGHA.564@TK2MSFTNGP12.phx.gbl...
>> 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

>
>



  Reply With Quote
Old 03-03-2006, 12:48 PM   #5
Sergey Bogdanov
Guest
 
Posts: n/a
Default Re: ToOADate method

.... 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


RobertM wrote:
> Hi Sergey
>
> thanks a lot but i don't understand C# code
> any clue with vb code ?
>
> regards
>
> "Sergey Bogdanov" <sergey.bogdanov@gmail.com> a ecrit dans le message de
> news: u7TwwvpPGHA.564@TK2MSFTNGP12.phx.gbl...
>> 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

>
>

  Reply With Quote
Old 03-03-2006, 01:47 PM   #6
RobertM
Guest
 
Posts: n/a
Default Re: ToOADate method

thanks a lot

"Sergey Bogdanov" <sergey.bogdanov@gmail.com> a ecrit dans le message de
news: unIFJDsPGHA.2012@TK2MSFTNGP14.phx.gbl...
> ... 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
>
>
> RobertM wrote:
>> Hi Sergey
>>
>> thanks a lot but i don't understand C# code
>> any clue with vb code ?
>>
>> regards
>>
>> "Sergey Bogdanov" <sergey.bogdanov@gmail.com> a ecrit dans le message de
>> news: u7TwwvpPGHA.564@TK2MSFTNGP12.phx.gbl...
>>> 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

>>


  Reply With Quote
Old 03-03-2006, 01:48 PM   #7
RobertM
Guest
 
Posts: n/a
Default Re: ToOADate method

what's wrong with you ?

"<ctacke/>" <ctacke_AT_OpenNETCF_com> a écrit dans le message de news:
e7L4nSrPGHA.5352@TK2MSFTNGP10.phx.gbl...
> http://www.danielmoth.com/Blog/2005...ting-to-ng.html
>
> See point #11
>
> -Chris
>
>
> "RobertM" <f> wrote in message
> news:Ojt1GJqPGHA.5464@TK2MSFTNGP11.phx.gbl...
>> Hi Sergey
>>
>> thanks a lot but i don't understand C# code
>> any clue with vb code ?
>>
>> regards
>>
>> "Sergey Bogdanov" <sergey.bogdanov@gmail.com> a ecrit dans le message de
>> news: u7TwwvpPGHA.564@TK2MSFTNGP12.phx.gbl...
>>> 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

>>
>>

>
>



  Reply With Quote
Old 03-03-2006, 02:19 PM   #8
Chris Tacke, MVP
Guest
 
Posts: n/a
Default Re: ToOADate method


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
news:%23I4roksPGHA.2704@TK2MSFTNGP15.phx.gbl...
> what's wrong with you ?
>
> "<ctacke/>" <ctacke_AT_OpenNETCF_com> a écrit dans le message de news:
> e7L4nSrPGHA.5352@TK2MSFTNGP10.phx.gbl...
>> http://www.danielmoth.com/Blog/2005...ting-to-ng.html
>>
>> See point #11
>>
>> -Chris
>>
>>
>> "RobertM" <f> wrote in message
>> news:Ojt1GJqPGHA.5464@TK2MSFTNGP11.phx.gbl...
>>> Hi Sergey
>>>
>>> thanks a lot but i don't understand C# code
>>> any clue with vb code ?
>>>
>>> regards
>>>
>>> "Sergey Bogdanov" <sergey.bogdanov@gmail.com> a ecrit dans le message de
>>> news: u7TwwvpPGHA.564@TK2MSFTNGP12.phx.gbl...
>>>> 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
>>>
>>>

>>
>>

>
>



  Reply With Quote
Old 03-03-2006, 02:40 PM   #9
Chris Tacke, MVP
Guest
 
Posts: n/a
Default Re: ToOADate method

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

http://www.danielmoth.com/Blog/2005...-level-000.html

-Chris

"RobertM" <f> wrote in message
news:%23I4roksPGHA.2704@TK2MSFTNGP15.phx.gbl...
> what's wrong with you ?
>
> "<ctacke/>" <ctacke_AT_OpenNETCF_com> a écrit dans le message de news:
> e7L4nSrPGHA.5352@TK2MSFTNGP10.phx.gbl...
>> http://www.danielmoth.com/Blog/2005...ting-to-ng.html
>>
>> See point #11
>>
>> -Chris
>>
>>
>> "RobertM" <f> wrote in message
>> news:Ojt1GJqPGHA.5464@TK2MSFTNGP11.phx.gbl...
>>> Hi Sergey
>>>
>>> thanks a lot but i don't understand C# code
>>> any clue with vb code ?
>>>
>>> regards
>>>
>>> "Sergey Bogdanov" <sergey.bogdanov@gmail.com> a ecrit dans le message de
>>> news: u7TwwvpPGHA.564@TK2MSFTNGP12.phx.gbl...
>>>> 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
>>>
>>>

>>
>>

>
>



  Reply With Quote
Old 03-03-2006, 03:06 PM   #10
RobertM
Guest
 
Posts: n/a
Default Re: ToOADate method

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


"Chris Tacke, MVP" <ctacke@spamfree-opennetcf.org> a écrit dans le message
de news: uzpEh2sPGHA.648@TK2MSFTNGP14.phx.gbl...
>
> 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
> news:%23I4roksPGHA.2704@TK2MSFTNGP15.phx.gbl...
>> what's wrong with you ?
>>
>> "<ctacke/>" <ctacke_AT_OpenNETCF_com> a écrit dans le message de news:
>> e7L4nSrPGHA.5352@TK2MSFTNGP10.phx.gbl...
>>> http://www.danielmoth.com/Blog/2005...ting-to-ng.html
>>>
>>> See point #11
>>>
>>> -Chris
>>>
>>>
>>> "RobertM" <f> wrote in message
>>> news:Ojt1GJqPGHA.5464@TK2MSFTNGP11.phx.gbl...
>>>> Hi Sergey
>>>>
>>>> thanks a lot but i don't understand C# code
>>>> any clue with vb code ?
>>>>
>>>> regards
>>>>
>>>> "Sergey Bogdanov" <sergey.bogdanov@gmail.com> a ecrit dans le message
>>>> de news: u7TwwvpPGHA.564@TK2MSFTNGP12.phx.gbl...
>>>>> 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
>>>>
>>>>
>>>
>>>

>>
>>

>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off