473,800 Members | 2,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to convert string into time format in asp.net

1 New Member
I have 00:01:00 in a string.
I want to convert it into time format.
How can i do this?
Aug 24 '07 #1
4 11240
kenobewan
4,871 Recognized Expert Specialist
I assume that this represents 1 min. Either way split the string and convert to time. HTH.
Aug 24 '07 #2
chazcross
31 New Member
im not sure if this is what you want

Expand|Select|Wrap|Line Numbers
  1. string s = "00:01:00";
  2. DateTime d = DateTime.Parse(s);
  3. Response.Write(d.ToShortTimeString());
this will return 12:01 AM
Aug 29 '07 #3
baldrex
8 New Member
hmm...

I have something similar to this but in my case this will not work. I have a text field storing the value in mins in this format 000100 representing 1 min.

I need to break this into a time reference 00:01:00 so that I can use it to calculate total time spent.

I have tried several different date/time functions but they all add the date, which I do not need.

question is: is there a way to convert this text into a time only field ?

i.e. Duration time/duration
005005 ... 00:50:05
000905 ... 00:09:05
001500 ... 00:15:00

total 01:14:10

thanks for you help!
Aug 30 '07 #4
Plater
7,872 Recognized Expert Expert
TimeSpan object.
(Note: They inter-twine very well with the DateTime object)
But you should be able to create a timespan object from a number of secods or minutes, or whatever
Aug 30 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
29037
by: fred14214 | last post by:
I need to be able to enter an elapsed time into a text field. This time then needs to be converted into seconds and stored in a field in some table. The user will enter a time (format is h:minutes:seconds) as such: 0:15:34 (0 hours, 15 minutes, 34 seconds -> 934 seconds total) or as another example:
1
3412
by: Bruce Cushman | last post by:
My DB is Access 2000 based "possibly written in 2002" and I have to send and receive update files, ported to a UNIX server by FTP, DB unknown. The file content uses a fixed length string, zero filled left. ie; 001332001695001995040601040630 where, 001332,001695,001995,040601,040630
1
10714
by: seash | last post by:
H when i execute this query, my query is crashing throwing an exception "cant convert char datatype to datetime type format my query is "insert into mytable(mydate) values ('"+ varmydate+ "') iam passing date format as dd/mm/yyyy my system date is in format dd/mm/yyyy is there any problem with sql server inaccepting the above format, or is there any way(universal) to send the datetime format to sql server
3
7637
by: Just D | last post by:
Did anybody see this bug? I tried to reproduce that using 12-hour and 24-hour system settings. Anyway it still causes a problem in VS2003. When I convert DateTime to a string using default ToString(), like DateTime.Now.ToString() C# returns me this string instead of a correct one: "19:25:35 PM". That's nonsense, but when I try to use DateTime.Parse(ThisString) it causes a fatal error, because this string doesn't look like as a time string....
0
1653
by: RSH | last post by:
Hi, I have a situation where I am using a dataset from a SQL Query. SQL's DateTime is a "long date/time field" which includes the Date/Time. My fields need to be displayed in a short time format "08:00" instead of "1/1/1900 08:00 AM"? I can't alter the database table, I only want to change the displayed value. How do I either change the datatable's column datatype to a string...or specify the columns formatting? How can I achieve...
5
19188
nirmalsingh
by: nirmalsingh | last post by:
i am getting date format in string as 30-11-2006 05:59:44 PM . i want to convert in the format of yyyy-mm-dd hh:mm:ss to sore it in mysql database. Help me with sample coding plz..
15
7659
by: shiniskumar | last post by:
How to convert string to double? Ive got a double variable dTot; its value is 5.037717235E7 when i did FreemarkerTools.formatDecimal(dTot) i got it as string "50377172.35". now i want to pass it as a double value to the method format() which is shown below. when i do Double.parseDouble i get dTot as 5.037717235E7 CurrencyConverter.format(Double.parseDouble(FreemarkerTools.formatDecimal(dTot)));
5
20843
by: rouven | last post by:
Hi, i am trying to convert that time format '05:26:40 Jun 19, 2007 PDT' into mysql compatible format like YYYY-MM-DD HH:MM:SS. the code i tried was: from datetime import datetime from time import strptime f1.write("strptime(%r); locale: %r" % (olddate, locale.getlocale())) newdate = time.strptime(olddate, "%H:%M:%S %b %d, %Y %Z") mysqldate = time.strftime("%Y-%m-%d %H:%M:%S", newdate)
18
13048
by: Dirk Hagemann | last post by:
Hello, From a zone-file of a Microsoft Active Directory integrated DNS server I get the date/time of the dynamic update entries in a format, which is as far as I know the hours since january 1st 1901. For Example: the number 3566839 is 27.11.07 7:00. To calculate this in Excel I use this: ="01.01.1901"+(A1/24-(REST(A1;24)/24))+ZEIT(REST(A1;24);0;0) (put 3566839 in field A1 and switch the format of the result-field to the corresponding...
0
9690
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
9551
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
10504
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10274
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
10251
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
10033
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...
1
7576
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
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
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.