Today, I am going to describe how to convert timeSpan value which may be difference between two dates. Even need to developer for calculate total duration between from date and To Date.
If we need to calculate duration between two dates we can use of TimeSpan.
I am giving some example in VB and C# code to calculate duration between two dates in days,hours,minutes as . .
//C# Code
'VB Code
'---------------
Dim Now As DateTime = DateTime.Now
Dim Preveous As DateTime = Now.AddHours(-5.5)
Dim Diference As TimeSpan = Now - Preveous
Response.Write(Diference.Days.ToString() & " Days, " & Diference.Hours.ToString() & " Hours, " & Diference.Minutes.ToString() & " Minuts")
If we need to calculate duration between two dates we can use of TimeSpan.
I am giving some example in VB and C# code to calculate duration between two dates in days,hours,minutes as . .
//C# Code
DateTime Now = DateTime.Now; DateTime Preveous = Now.AddHours(-5.5); TimeSpan Diference = Now - Preveous; Response.Write(Diference.Days.ToString() + " Days, " + Diference.Hours.ToString() + " Hours, "
+ Diference.Minutes.ToString() + " Minutes");
'VB Code
'---------------
Dim Now As DateTime = DateTime.Now
Dim Preveous As DateTime = Now.AddHours(-5.5)
Dim Diference As TimeSpan = Now - Preveous
Response.Write(Diference.Days.ToString() & " Days, " & Diference.Hours.ToString() & " Hours, " & Diference.Minutes.ToString() & " Minuts")
No comments:
Post a Comment