Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format time

Status
Not open for further replies.

SQL2KDBA69

Programmer
Feb 4, 2004
227
US
im trying to format 600 sec to mins and seconds. So i want 600s to look like 10:00 which is the mm:ss format.

thanks in advance
 
You could throw them into a string manually.

Code:
public function FormatSeconds(Seconds as integer) as string
  dim iMinutes = Seconds \ 10
  dim iSeconds as integer = Seconds MOD 10
  return iMinutes & ":" & iSeconds
end function

Or you could try a timespan (I have no idea if this will work, it just popped into my head:
Code:
  Dim ts As TimeSpan = TimeSpan.FromSeconds(600)
  mystring = ts.Minutes & ":" & ts.seconds

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
public function FormatSeconds(Seconds as integer) as string
dim iMinutes = Seconds \ 60
dim iSeconds as integer = Seconds MOD 60
return iMinutes & ":" & iSeconds
end function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top