471,354 Members | 1,841 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.

How can I format this date

Hi,
When I use msgbox(Now().ToShortDateString) I get 4/21/2005. How can I
convert that to 042105.

Thanks
Jul 21 '05 #1
2 1068
On Thu, 21 Apr 2005 09:43:17 -0700, Chris wrote:
Hi,
When I use msgbox(Now().ToShortDateString) I get 4/21/2005. How can I
convert that to 042105.

Thanks


DateTime.Now.ToString("MMddYY");

--
Claudio Grazioli
http://www.grazioli.ch
http://www.grazioli.ch/HommingbergerGepardenforelle/
Jul 21 '05 #2
On Thu, 21 Apr 2005 09:43:17 -0700, "Chris"
<Ch***@discussions.microsoft.com> wrote:
Hi,
When I use msgbox(Now().ToShortDateString) I get 4/21/2005. How can I
convert that to 042105.

Thanks


Assuming that the result you want is a string "042105" and not an
integer then you need to parse the given string.

First locate the two slashes and split the input into three parts.
You may want to use String.Split() to do this.
Second look at the length of each separate part and either add a '0'
on the front or chop off the first two characters as required.
Third concatenate the three parts to give the result.

If you have difficulties with this then post your code here and we can
have a look at it.

rossum

The ultimate truth is that there is no ultimate truth
Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Simon Brooke | last post: by
5 posts views Thread by Macca | last post: by
20 posts views Thread by andreas | last post: by
reply views Thread by XIAOLAOHU | 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.