In Above screenshot totalHours variable is Generic and timeDifference is also Generic.
timeDifference variable output i am getting as 00:00:00(HH:MM:SS) and i want that in 00:00(HH:MM).
I did this TimeSpan.Parse(timeDifference).ToString(“HH:mm”) but its throwing error.
supriya117
(Supriya Allada)
2
Hi @Puneet_Singh1
Try this:
totalHours = TimeSpan.Parse(timeDifference).ToString("hh\:mm")
rlgandu
(Rajyalakshmi Gandu)
3
@Puneet_Singh1
string timeDifferenceString = “00:00:00”;
// Convert the string to a TimeSpan object.
TimeSpan timeDifference = TimeSpan.Parse(timeDifferenceString, DateTimeFormatInfo.InvariantCulture);
// Get the hours and minutes from the TimeSpan object.
int hours = timeDifference.Hours;
int minutes = timeDifference.Minutes;
// Format the hours and minutes as a string.
string formattedTimeDifference = string.Format(“{0}:{1}”, hours, minutes);
Not Working. Totalhours are showing as 0.5 and when i am converting into minutes it showing 00:00
supriya117
(Supriya Allada)
6
Try:
> timeDifference.ToString("hh\:mm")
lrtetala
(Lakshman Reddy)
7
Hi @Puneet_Singh1
Try this
DateTime.Now.ToString(“HH:mm”)
lrtetala
(Lakshman Reddy)
8
Hi @Puneet_Singh1
Try this
DateTime.ParseExact(dATRER,"HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture)
Regards,
lrtetala
(Lakshman Reddy)
9
@Puneet_Singh1
Try this also
DateTime.ParseExact(dATRER,"HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture).ToString("HH:mm")
I hope you understand!!
lrtetala
(Lakshman Reddy)
10
Hi @Puneet_Singh1
If you got the solution for your question. Please mark it as solution to close the thread.
Regards,
system
(system)
Closed
11
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.