![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
DateTime.FromOADate() Method in C#
The DateTime.FromOADate() method in C# is used to return a DateTime equivalent to the specified OLE Automation Date.
Syntax
Following is the syntax −
public static DateTime FromOADate (double val);
Above, Val is the OLE Automation Date value.
Example
Let us now see an example to implement the DateTime.FromOADate() method −
using System; public class Demo { public static void Main() { DateTime d1 = DateTime.FromOADate(1.0); Console.WriteLine("DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ",d1); } }
Output
This will produce the following output −
DateTime = 31 December 1899, 12:00:00
Example
Let us now see another example to implement the DateTime.FromOADate() method −
using System; public class Demo { public static void Main() { DateTime d1 = DateTime.FromOADate(375765.0); DateTime d2 = DateTime.FromOADate(0.0); Console.WriteLine("DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ",d1); Console.WriteLine("New DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ",d2); } }
Output
This will produce the following output −
DateTime = 21 October 2928, 12:00:00 New DateTime = 30 December 1899, 12:00:00
Advertisements