Change date format to YYYYMMDD

pvg1975
pvg1975 used Ask the Experts™
on
Hello all,

Im migrating a product and I need to do the following.

I need to convert the current date, to the current date plus 1 month, and get the results in the following format. For example, for today:

08/04/2011

I need to get

20110904 (notice the month is the current month + 1)

How can I do this with VB.NET?

Thanks!

Paula
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
I got it, its Format(DateTime.Now.AddMonths(1), "yyyyMMdd")

:)
Commented:
String.Format("{0:yyyyMMdd", DateTime.Now.AddMonths(1))
Most Valuable Expert 2012
Top Expert 2014
Commented:
Another approach is (for your future reference)

Today.AddMonths(1).ToString("yyyyMMdd")
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009
Commented:
That'll work.

You can also use ToString(), instead of Format(), like this:

    DateTime.Now.AddMonths(1).ToString("yyyyMMdd")
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009

Commented:
Sorry!  ECHO...ECHo...ECho...Echo...echo...ech...ec...e...  =)

Author

Commented:
Points splitted among you all :)

Thanks guys,

Sumitting a new question in 2 minutes.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial