Solved

# Datetime integer

Posted on 2009-12-27
Medium Priority
207 Views
I've got the following xml ( from third party)

<performance_start>1217617200</performance_start>
<performance_end>1217620800</performance_end>

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
0
Question by:frosty1

LVL 42

Accepted Solution

Meir Rivkin earned 2000 total points
ID: 26127189
it looks like the number of ticks that represent the start/end of the opertation:
Dim ts As TimeSpan
ts = TimeSpan.FromTicks(1217617200)

0

LVL 9

Expert Comment

ID: 26127192
Try this.
DateTime time = new DateTime((long)1217617200);
0

LVL 9

Expert Comment

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

LVL 42

Expert Comment

ID: 26127210
to calculate the elapsed time, just use this:

Dim elapseTime As TimeSpan

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

LVL 11

Expert Comment

ID: 26127850
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.
0

Author Comment

ID: 26127863
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.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…