PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
ToOADate method
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
ToOADate method
![]() |
ToOADate method |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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 > > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#4 |
|
Guest
Posts: n/a
|
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 > > |
|
|
|
#5 |
|
Guest
Posts: n/a
|
.... 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 > > |
|
|
|
#6 |
|
Guest
Posts: n/a
|
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 >> |
|
|
|
#7 |
|
Guest
Posts: n/a
|
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 >> >> > > |
|
|
|
#8 |
|
Guest
Posts: n/a
|
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 >>> >>> >> >> > > |
|
|
|
#9 |
|
Guest
Posts: n/a
|
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 >>> >>> >> >> > > |
|
|
|
#10 |
|
Guest
Posts: n/a
|
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 >>>> >>>> >>> >>> >> >> > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

