432,257 Members | 925 Online
Need help? Post your question and get tips & solutions from a community of 432,257 IT Pros & Developers. It's quick & easy.

# Convert seconds to days, hours, minutes and seconds.

 P: n/a Hello - I have about ten integer values that each need to be converted to days, hours, minutes and seconds. I can't seem to find a formula for same that works. These integer values come from a Sql Server database that SUMS up the seconds. The only way SUM will work in SS is with an integer value, therefore, I could not use datetime in Sql Server.) I need to ultimately put the converted values into ten datetimepicker controls. Does anyone have code for doing this? Any help will be appreciated! -- Sheldon Jul 5 '08 #1
5 Replies

 P: n/a On Jul 5, 3:37*pm, Sheldon

 P: n/a "Sheldon"

 P: n/a "Sheldon"

 P: n/a Sheldon wrote: Hello - I have about ten integer values that each need to be converted to days, hours, minutes and seconds. I can't seem to find a formula for same that works. These integer values come from a Sql Server database that SUMS up the seconds. The only way SUM will work in SS is with an integer value, therefore, I could not use datetime in Sql Server.) I need to ultimately put the converted values into ten datetimepicker controls. Does anyone have code for doing this? Any help will be appreciated! The most straight forward method is to simply turn the seconds into a TimeSpan value: t AS TimeSpan = TimeSpan.FromSeconds(seconds) If you need a DateTime value, you have to pick a date that you start counting from (i.e. the date that a zero seconds value would represent). Then you just add the seconds to that. d As DateTime = new DateTime(2008,1,1).AddSeconds(seconds) -- GÃ¶ran Andersson _____ http://www.guffa.com Jul 6 '08 #5

 P: n/a "Sheldon"

### This discussion thread is closed

Replies have been disabled for this discussion.