Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to convert from string to timespan
Posted
Comments
agent_kruger 2-Feb-14 1:14am    
sir, please try & search on google before asking the question here.

 
Share this answer
 
try
C#
string values = "000000006";
TimeSpan interval = TimeSpan.Parse(value);
 
Share this answer
 
Comments
Member 10548723 1-Feb-14 1:26am    
what's the values?

for example i want store 09:00am in my db, my db is time(7) data type
kedar001 1-Feb-14 1:30am    
Please elaborate...
if you want to convert string to timespan for example "09:00 AM". Just try this
DateTime dt = DateTime.Parse("09:00 PM");
TimeSpan ts = new TimeSpan(dt.Hour, dt.Minute, dt.Second);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900