Hello Everyone,
Can you help to converting Timespan format to the String in “HH:mm” format?
Example:
var timeSpan = [1.03:34:23.8121360] , which is 1 day 3 hours 34 minutes xxx
var String = “27:34” , which is 27 hours 34 minutes
Regards,
Brian
Hello Everyone,
Can you help to converting Timespan format to the String in “HH:mm” format?
Example:
var timeSpan = [1.03:34:23.8121360] , which is 1 day 3 hours 34 minutes xxx
var String = “27:34” , which is 27 hours 34 minutes
Regards,
Brian
Hi @henokhbrian
Try this below expression
System.Math.Floor(variable.TotalHours).ToString & variable.ToString(“:HH:mm”)
Regards
Gokul
Hi @henokhbrian ,
Timespan might contain the keyword “Time” in it, but it has nothing to do with Dates, which is why we can’t use string implementations.
Its a collection of ticks, so the only workaround for it is like so:
Assign →
spn_variable = TimeSpan.Parse("1.03:34:23.8121360")
spn_variable.Hours.ToString+":"+spn_variable.Seconds.ToString
Or
String.Format("{0}:{1}",spn_variable.Hours,spn_variable.Seconds)
I hope that helps.
Kind Regards,
Ashwin A.K
@nikhil.girish , @Steven_McKeering , @Gokul001 , @ashwin.ashok
thanks you for your attention and your help for my question. In other way, i have tried combine the methods from your answers to this:
System.Math.Floor(timespanVariable.TotalHours).ToString + “:” + timespanVariable.Minutes.ToString
and the output is: “27:34”