DateTime.FromOADate() Method in C# Last Updated : 28 Jan, 2019 Comments Improve Suggest changes Like Article Like Report DateTime.FromOADate(Double) Method is used to return a DateTime equivalent to the specified OLE Automation Date. Syntax: public static DateTime FromOADate (double d); Here, it takes an OLE Automation Date value. Return Value: This method returns an object that represents the same date and time as d. Exception: This method will give ArgumentException if the date is not a valid OLE Automation Date value. Below programs illustrate the use of DateTime.FromOADate(Double) Method: Example 1: csharp // C# program to demonstrate the // DateTime.FromOADate(Int64) Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { try { // converting 657435.0 OLE // Automation Date value. // into DateTime format // using FromOADate() method DateTime date2 = DateTime.FromOADate(657435.0); // Display the date2 System.Console.WriteLine("DateTime " + ": {0:y} {0:dd}",date2); } catch (ArgumentException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: DateTime : 3699 December 28 Example 2: For ArgumentException csharp // C# program to demonstrate the // DateTime.FromOADate(Int64) Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { try { // converting 657435.0 OLE // Automation Date value. // into DateTime format // using FromOADate() method DateTime date2 = DateTime.FromOADate(-657435.0); // Display the date2 System.Console.WriteLine("DateTime " + ": {0:y} {0:dd}",date2); } catch (ArgumentException e) { Console.WriteLine("The date is not a valid "+ "OLE Automation Date value."); Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: The date is not a valid OLE Automation Date value. Exception Thrown: System.ArgumentException Reference: https://docs.microsoft.com/en-us/dotnet/api/system.datetime.fromoadate?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article DateTime.FromOADate() Method in C# rohitprasad3 Follow Improve Article Tags : C# CSharp DateTime Struct CSharp-method Similar Reads DateTime.FromFileTime() Method in C# DateTime.FromFileTime(Int64) Method is used to converts the specified Windows file time to an equivalent local time. Syntax: public static DateTime FromFileTime (long fileTime); Here, it takes a Windows file time expressed in ticks. Return Value: This method returns an object that represents the loc 2 min read DateTime.FromBinary() Method in C# DateTime.FromBinary(Int64) Method is used to deserialize a 64-bit binary value and recreates an original serialized DateTime object. Syntax: public static DateTime FromBinary (long dateData); Here, it takes a 64-bit signed integer that encodes the Kind property in a 2-bit field and the Ticks propert 2 min read DateTime.FromFileTimeUtc() Method in C# DateTime.FromFileTimeUtc(Int64) Method is used to convert the specified Windows file time to an equivalent UTC time. Syntax: public static DateTime FromFileTimeUtc (long fileTime); Here, it takes a Windows file time expressed in ticks.Return Value: This method returns an object that represents the U 2 min read DateTimeOffset.FromFileTime() Method in C# DateTimeOffset.FromFileTime(Int64) Method is used to convert the specified Windows file time to an equivalent local time. Syntax: public static DateTimeOffset FromFileTime (long fileTime); Here, it takes a Windows file time, expressed in ticks. Return Value: This method returns an object that repres 2 min read DateTime.GetTypeCode() Method in C# This method is used to return the TypeCode for value type DateTime. Syntax: public TypeCode GetTypeCode (); Return Value: This method returns the enumerated constant, DateTime. Below programs illustrate the use of DateTime.GetTypeCode() Method Example 1: csharp // C# program to demonstrate the // Da 1 min read DateTime.DaysInMonth() Method in C# This method returns the number of days in the specified month and year. This method always interprets month and year as the month and year of the Gregorian calendar even if the Gregorian calendar is not the current culture's current calendar. Syntax: public static int DaysInMonth (int year, int mont 2 min read DateTime.Add() Method in C# This method is used to return a new DateTime that adds the value of the specified TimeSpan to the value of this instance. Syntax: public DateTime Add (TimeSpan value); Here, value is a positive or negative time interval. Return Value: This method returns an object whose value is the sum of the date 2 min read DateTimeOffset.Add() Method in C# This method is used to return a new DateTimeOffset object that adds a specified time interval to the value of this instance. Syntax: public DateTimeOffset Add (TimeSpan timeSpan); Here, it takes a TimeSpan object that represents a positive or a negative time interval.Return Value: This method return 2 min read DateTimeOffset.FromUnixTimeSeconds() Method in C# DateTimeOffset.FromUnixTimeSeconds(Int64) Method is used to convert a Unix time expressed as the number of seconds that have elapsed since 1970-01-01T00:00:00Z to a DateTimeOffset value. Syntax: public static DateTimeOffset FromUnixTimeSeconds (long seconds); Here, it takes a Unix time, expressed as 2 min read DateTimeOffset.EqualsExact() Method in C# DateTimeOffset.EqualsExact(DateTimeOffset) Method is used to determine whether the current DateTimeOffset object represents the same time and has the same offset as a specified DateTimeOffset object. Syntax: public bool EqualsExact (DateTimeOffset other); Here, it takes the object to compare to the 2 min read Like