Click here to Skip to main content
15,917,328 members
Home / Discussions / C#
   

C#

 
AnswerMessage Removed Pin
19-Mar-12 0:32
Vipin_Arora19-Mar-12 0:32 
GeneralRe: restoring database using c# Pin
altafmohd19-Mar-12 0:49
altafmohd19-Mar-12 0:49 
QuestionProgramming RFID in c#.net Pin
yutalolap18-Mar-12 0:38
yutalolap18-Mar-12 0:38 
AnswerRe: Programming RFID in c#.net Pin
Richard MacCutchan18-Mar-12 2:17
mveRichard MacCutchan18-Mar-12 2:17 
QuestionGetting the date from a timespan Pin
CCodeNewbie17-Mar-12 14:37
CCodeNewbie17-Mar-12 14:37 
AnswerRe: Getting the date from a timespan Pin
Ravi Bhavnani17-Mar-12 14:55
professionalRavi Bhavnani17-Mar-12 14:55 
AnswerRe: Getting the date from a timespan Pin
Luc Pattyn17-Mar-12 15:02
sitebuilderLuc Pattyn17-Mar-12 15:02 
GeneralRe: Getting the date from a timespan Pin
CCodeNewbie18-Mar-12 1:35
CCodeNewbie18-Mar-12 1:35 
Hi Luc,

Thanks for your reply but I just can't seem to find the error.

C#
long dt1 = DateTime.Now.Ticks;
long dt2 = procs.StartTime.Ticks;
long dt3 = new DateTime(1601, 1, 1, 0, 0, 0).AddTicks(dt2).Ticks;
long ts = (dt1 - dt3) / 10000000;
DateTime ST = new DateTime(ts);

result - System.ArgumentOutOfRangeException: Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
Parameter name: ticks
C#
long dt1 = DateTime.Now.Ticks;
long dt2 = procs.StartTime.Ticks;
long st = (dt1 - dt2)/10000000;
DateTime ST = new DateTime(st);

result - Arithmetic overflow error converting expression to data type datetime,
C#
DateTime dt1 = DateTime.Now;
DateTime dt2 = procs.StartTime;
DateTime dt3 = new DateTime(1601, 1, 1, 0, 0, 0);
DateTime st = dt3.AddSeconds(dt2);//cannot convert from datetime to doouble
DateTime result = new DateTime(dt1.Subtract(st));//cannot convert from timespan to long

result - none
C#
DateTime dt1 = DateTime.Now;
DateTime dt2 = procs.StartTime;
TimeSpan ts = dt1.Subtract(dt2);
DateTime result = DateTime.Now.Subtract(ts);

result - 01/01/1601 00:00:00

What am I missing?
AnswerRe: Getting the date from a timespan Pin
Luc Pattyn18-Mar-12 2:06
sitebuilderLuc Pattyn18-Mar-12 2:06 
GeneralRe: Getting the date from a timespan Pin
CCodeNewbie18-Mar-12 4:47
CCodeNewbie18-Mar-12 4:47 
GeneralRe: Getting the date from a timespan Pin
Dave Kreskowiak18-Mar-12 7:26
mveDave Kreskowiak18-Mar-12 7:26 
GeneralRe: Getting the date from a timespan Pin
CCodeNewbie18-Mar-12 7:32
CCodeNewbie18-Mar-12 7:32 
GeneralRe: Getting the date from a timespan Pin
jschell18-Mar-12 7:26
jschell18-Mar-12 7:26 
GeneralRe: Getting the date from a timespan Pin
CCodeNewbie18-Mar-12 7:41
CCodeNewbie18-Mar-12 7:41 
GeneralRe: Getting the date from a timespan Pin
jschell19-Mar-12 8:30
jschell19-Mar-12 8:30 
Answerbooted=DateTime.Now.AddMilliseconds(-Environment.TickCount); Pin
Luc Pattyn18-Mar-12 9:46
sitebuilderLuc Pattyn18-Mar-12 9:46 
GeneralRe: Getting the date from a timespan Pin
BobJanova19-Mar-12 0:20
BobJanova19-Mar-12 0:20 
GeneralRe: Getting the date from a timespan Pin
CCodeNewbie19-Mar-12 1:25
CCodeNewbie19-Mar-12 1:25 
GeneralRe: Getting the date from a timespan Pin
BobJanova19-Mar-12 1:44
BobJanova19-Mar-12 1:44 
GeneralRe: Getting the date from a timespan Pin
CCodeNewbie19-Mar-12 3:22
CCodeNewbie19-Mar-12 3:22 
GeneralRe: Getting the date from a timespan Pin
BobJanova19-Mar-12 3:52
BobJanova19-Mar-12 3:52 
GeneralRe: Getting the date from a timespan Pin
CCodeNewbie19-Mar-12 4:21
CCodeNewbie19-Mar-12 4:21 
GeneralRe: Getting the date from a timespan Pin
BobJanova19-Mar-12 6:37
BobJanova19-Mar-12 6:37 
GeneralRe: Getting the date from a timespan Pin
CCodeNewbie19-Mar-12 6:59
CCodeNewbie19-Mar-12 6:59 
GeneralRe: Getting the date from a timespan Pin
CCodeNewbie19-Mar-12 12:18
CCodeNewbie19-Mar-12 12:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.