473,796 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting int seconds to datetime or formated string

I am pulling an integer value of the amount of seconds since 12:00 am from a
SQL Server DB. I want to convert this integer into a formated string or
datetime to display a legible time of day. Are there any built in methods in
the .NET framework that will accomplish this. If not, any other suggestion
about creating a method to do this would be appretiated.
Thanks
Mar 2 '06 #1
2 28059
DateTime dt = new DateTime(year, month, day, 0, 0, 0);

dt.Add(new TimeSpan(0,0,nu mberOfSecs);

Is that what you mean?

"Pat Brown" <Pa******@discu ssions.microsof t.com> wrote in message
news:48******** *************** ***********@mic rosoft.com...
I am pulling an integer value of the amount of seconds since 12:00 am from
a
SQL Server DB. I want to convert this integer into a formated string or
datetime to display a legible time of day. Are there any built in methods
in
the .NET framework that will accomplish this. If not, any other
suggestion
about creating a method to do this would be appretiated.
Thanks

Mar 2 '06 #2
Pat Brown wrote:
I am pulling an integer value of the amount of seconds
since 12:00 am
Since you didn't specify what date, I am going to assume it is always from
12:00am today.
I want to convert this integer into a formated string or
datetime to display a legible time of day.


A few ideas to get you started:
DateTime foo = DateTime.Now.Da te.AddSeconds(s econds);

string foo = string.Format(" {0:00}:{1:00}", seconds / 3600, seconds % 3600 /
60);
--
Chris Priede
Mar 2 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
316
by: Mark Worrall | last post by:
I am being supplied a count of number of seconds since Jan 1st 1970, i.e. a Unix system time. How can I convert this into a valid .Net DateTime object ? thanks, Mark WinXP / C#.Net 2003
2
9297
by: Roy Rodsson via .NET 247 | last post by:
Hi all! I am using a stored procedure in SQL2000 for retrieving fileinformations from a db. the table as an uniqueidentifier for the file information. The stored procedure has a variable called fileIds that is oftype varchar. I am putting in a comma separated string with ids (such as:'9B176B0C-CA03-49C9-A2E7-063038E7CF20','9B176B0C-CA03-49C9-A2E7-063038E7CF22','9B176B0C-CA03-49C9-A2E7-063038E7CF23') However, when I execute the sp via...
8
2490
by: Mika M | last post by:
Is there better way to convert integer type date into DateTime type date as doing like code below? Dim intDate As Integer = 20051019 Dim dte As DateTime = New DateTime( _ CType(intDate.ToString.Substring(0, 4), Integer), _ CType(intDate.ToString.Substring(4, 2), Integer), _ CType(intDate.ToString.Substring(6, 2), Integer))
11
6717
by: Rubic | last post by:
I was a little surprised to recently discover that datetime has no method to input a string value. PEP 321 appears does not convey much information, but a timbot post from a couple years ago clarifies things: http://tinyurl.com/epjqc > You can stop looking: datetime doesn't > support any kind of conversion from string.
1
1547
by: Mahathi | last post by:
Hi Can we convert DateTime to String. If so how? Thanks in advance. Mahathi.
6
4130
by: B.N.Prabhu | last post by:
Hi, I am having a DataTable which one column is in string format now i want to change that one to DataTime. I don't know whether its in datetime format or not i have to check if it is in DateTime Format some times it may in normal string not a DateTime. If it is in any one of the DateTime format then i have to change it as a Specfic format as "21-03-2005 11:34" using C#.Net. If its not in DateTime format then i should give a message.
1
1926
by: Vishal Bhargava | last post by:
Is there an inbuilt library in Python which you can use to convert time in seconds to hh:mm:ss format? Thanks, Vishal
2
11185
by: bipinskulkarni | last post by:
Hi, i have a field createdby with datatype GUID. In following query ,i encountered with the error "Conversion failed when converting from a character string to uniqueidentifier" select ISNULL(VW_tbl_ChildProducts.createdBy,' ' ) as createdBy from table.
4
1924
by: geeta719 | last post by:
void main() { char ch=""; char c; int k=0,l,i; printf("Enter a number:"); scanf("%d",&i); while(i!=0) //reversing a numbr { k=k*10+i%10; i=i/10;}
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9533
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10239
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10190
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10019
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9057
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6796
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.