1

I want to convert a double value to DateTime and do some operation on it and again convert back DateTime value to double. But I am unable to call DateTime.FromOADate() and DateTime.ToOADate(); the methods don't exist.

Please help to resolve this.

Per Lundberg
  • 3,837
  • 1
  • 36
  • 46
Uddhao Pachrne
  • 531
  • 1
  • 8
  • 22
  • Could you share some code? It's not clear what you're trying to achieve. – Mark Verkiel Apr 29 '16 at 09:04
  • @Pilatus : In my mvvmcross xamarin project DateTime.FromOADate method not available but in API project DateTIme.FromOADate method available. I think in Web project DateTime support FromOADate and ToOADate method but not support in mobile project. – Uddhao Pachrne Apr 29 '16 at 11:43
  • What operation do you want to do? – stefana May 03 '16 at 09:08
  • @Nfear : I getting working hours in UTC in double type from API. So I just want convert double value to DateTime and convert it into DateTime.ToLocalTime. And then convert DateTime value to double with local time to display. – Uddhao Pachrne May 03 '16 at 16:31

2 Answers2

2

I'm assuming that the project that isn't able to call ToOADate() and FromOADate() because it is a Portable Class Library (PCL).

The following SO post is about a different case but concludes that not all methods of System.Datetime are included.

Source: What happened to .ToShortDateString in .NET Portable Class Library

Community
  • 1
  • 1
Mark Verkiel
  • 1,229
  • 10
  • 22
2

I guess you are using .NET Core Framework and you won't find these methods DateTime.FromOADate() and DateTime.ToOADate() because the OLE Automation Date exist only .NET Framework and .NET Core is cross platform Framework.

Kos
  • 567
  • 4
  • 15
  • That's _exactly_ what I am doing which led me to this SO question... What puzzles me is that the `mscorelib` class in the coreclr repo seems to have this method: https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/DateTime.cs#L735 – Per Lundberg Feb 25 '17 at 20:18