-3

I want to store time 11:22:33 in table, but the time is stored like this 112233. How to insert : between the string

String text = "txtucrtime.Text,HH:MM:SS";
 var split = Regex.Split(text, @"(?<=[:::])");
No Idea For Name
  • 11,411
  • 10
  • 42
  • 70
Althaf Ahamed
  • 51
  • 1
  • 11
  • 2
    Do you use `DateTime` as datatype in your table? sql? mysql?.. a bit more info please... – DeMama Jul 24 '13 at 11:17
  • You should store the time in a native format of the database [if one is available in your RDBMS](http://msdn.microsoft.com/en-us/library/bb677243.aspx). Format it "at the last moment", when you about to display it to your users, or put it in another kind of output. – Sergey Kalinichenko Jul 24 '13 at 11:20
  • Can you give an insight on how it is inserted as `112233` ? your question is not clear as of now – V4Vendetta Jul 24 '13 at 11:21
  • 1
    @dasblinkenlight Most RDBMS systems have a datetime type of some description which aren't always suitable for storing time-only values. The system may require a storage for a time of day, rather than an exact time on an exact date – Tobsey Jul 24 '13 at 11:26

2 Answers2

0

See this question: Best way to store time (hh:mm) in a database

Assuming you want to store the time of day, store as an integer which represents the smallest precision you want. If you want to store time in seconds:

hours * 60 * 60
+ minutes * 60
+ seconds

If you want to store to the millisecond, multiple each of the values by 1000 prior to adding them, then also add the milliseconds portion of your time value.

Community
  • 1
  • 1
Tobsey
  • 3,390
  • 14
  • 24
0

String text = hrs + ":" + mins + ":"secs;

try these thanks

MohRizwan
  • 17
  • 4