Welcome Guest | My Membership | Login

Convert Internal Date into C#/VB.NET Date/Time


Summary

When working within DotNet (.NET), many times, developers need to convert MultiValue Internal Dates  into something C# or VB.NET will understand.  Many of the .NET APIs that are provided to you from your Database provider have the OCONV and ICONV functions available.

Using the OCONV and ICONV functions, you can always do the following to get an windows DateTime object:

Dim _InternalDate As String = "13548"
Dim _WinDate As Date
_WinDate = Date.Parse(session.Oconv(_InternalDate, "D4/"))

While this works well, sometimes you don’t have access to these APIs, or you may want to generate the output without the overhead of converting the information to a external format, and then parsing that format.

The DateTime object has the ability to convert an OA Date format.  The OA Date format is the number of days since December 30 1899.  So in order to convert a MultiValue internal date into a OA date, we just need to add an offset value.  The following code shows you how to do this:

Dim _InternalDate As String = "13548"
Dim _ZeroDate As New Date(1967, 12, 31)

Dim _OffsetDate As Double = _ZeroDate.ToOADate
Dim _WinDate As Date
_WinDate = DateTime.FromOADate(Integer.Parse(_InternalDate) + _OffsetDate)

Read More...

Social Media Login

Use your existing social media logins to access your Membership/Subscription information.

Existing Magazine/Newsletter Subscriber (Quick Access)

If you are an existing International Spectrum subscriber, but have not registered with the website, please enter the Reference Code found on the magazine or in the e-mails you receive from us.

Magazine Reference Code location

Spectrum Login

New Subscriber

If you currently do not receive the Magazine or other emails from International Spectrum, select the "Subscribe" button below to create an new membership account.


 

Find out more about the different between the FREE and a Professional Membership at:
Compare Account Options

 

# # #          # # #          # # #

 

Related Articles

  • MultiValue BASIC and C# Syntax Comparison

    MultiValue BASIC is excellent for developing Business and Enterprise console applications, as well as string manipulation and business rules. Many people chose to use .NET for the GUI and UI development, whether it is ASP.NET, WinForms, or XAML. When working in these environments, it is handy to have a cheat sheet of how each language implements it syntax.

  • Convert C#/VB.NET Date/Time to Internal Date

    This Article will show you how to convert a C# or VB.NET Date/Time object into an Internal MultiValue Date. It will show you how to do it using the ICONV functions, and well as how to generate an Internal Date without using the ICONV function.

  • Introducing OpenXML

    Company: Brian Leach Consulting, ltd

    With Word 2007, Microsoft introduced a new document format based on XML, thus opening the ability to work directly with the document structures. This first article introduces OpenXML and shows how to explore this new format.

  • MultiValue BASIC and VB.NET Syntax Comparison

    MultiValue BASIC is excellent for developing Business and Enterprise console applications, as well as string manipulation and business rules. Many people choose C#for the GUI and UI development, whether it is ASP.NET, WinForms, or XAML. When working in these environments, it is handy to have a cheat sheet of how each language implements it syntax.

  • MultiValue OCONV/ICONV in .NET - Date Conversion

    OCONV/ICONV commands are used extensively throughout our MultiValue systems. For many of us, they have become second nature, but to use them in other languages can cause problems. This article will explain how to mimic the OCONV/ICONV process in .NET for the Date Conversion codes.


Return to top