Datetime integer

Posted on 2009-12-27
Last Modified: 2012-05-08
I've got the following xml ( from third party)


I need to extract these dates. Though i dont know how to interrupt this format. How do you turn this int value into a datetime
Question by:frosty1
    LVL 42

    Accepted Solution

    it looks like the number of ticks that represent the start/end of the opertation:
            Dim ts As TimeSpan
            ts = TimeSpan.FromTicks(1217617200)

    LVL 9

    Expert Comment

    Try this.
                DateTime time = new DateTime((long)1217617200);
    LVL 9

    Expert Comment

    To calc the time span, you can also do this.
                DateTime start = new DateTime(1217617200);
                DateTime end = new DateTime(1217620800);
                TimeSpan ts = end - start;
    LVL 42

    Expert Comment

    to calculate the elapsed time, just use this:

         Dim elapseTime As TimeSpan

            elapseTime = TimeSpan.FromTicks(1217620800 - 1217617200)
            Console.WriteLine("elapseTime: {0}", elapseTime.ToString())
    LVL 11

    Expert Comment

    both solutions from MagicDf and sedgwick will give you the same answer.

    However I would personnaly try to get information about that 3rd party program before doing anything with those dates. Simple because unless you know for sure what those integers are they could be just about anything: worst case scenario is thatt XML is a response from a webservice coded in another language which may be spitting out the database representation of a date.

    Author Comment

    thanks guys, really good feedback. Seems like the third party left out the actual day. ie just gave the timespam. Really appreciate the response. Clarify things for me.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    26 Experts available now in Live!

    Get 1:1 Help Now