471,354 Members | 1,327 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Time Formatting - Please help!

Hi all,

I got a problem.. I want to format the time into a decimal value.. The
code that I used worked fine for some time but now it does not want to
work.... If any one can help me or give me alternative code... Thanks
in advance

Code:
++++

decimal.Parse(DateTime.Now.TimeOfDay.ToString().Re place(":","").Replace(".","").Remove(7,DateTime.No w.TimeOfDay.ToString().Length
- 7).Trim());

Error:
++++

Additional information: Index and count must refer to a location within
the string.

All help would be appreciated.
Paul

Dec 22 '05 #1
2 3644
Hi,

"PJHORNSA" <sp**@qbcon.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi all,

I got a problem.. I want to format the time into a decimal value.. The
code that I used worked fine for some time but now it does not want to
work.... If any one can help me or give me alternative code... Thanks
in advance

Code:
++++

decimal.Parse(DateTime.Now.TimeOfDay.ToString().Re place(":","").Replace(".","").Remove(7,DateTime.No w.TimeOfDay.ToString().Length
- 7).Trim());

That is terrible complex, just use ToString with a custom format and parse
it:

decimal.Parse( DateTime.Now.ToString("HHMMdd",
DateTimeFormatInfo.InvariantInfo );

note:
I did not tried to understand what format you want, just check MSDN for the
correct format string

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Dec 22 '05 #2
Thanx alot, it helped....

Dec 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by beliavsky | last post: by
reply views Thread by Ognjen Bezanov | last post: by
11 posts views Thread by lduperval | last post: by
1 post views Thread by Riko Eksteen | last post: by
7 posts views Thread by BBFrost | last post: by
9 posts views Thread by Bob Achgill | last post: by
8 posts views Thread by gopal | last post: by
6 posts views Thread by Tomasz J | last post: by

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.