Hello all,
Ive done some googling around, and cant find anything that explains why my date isnt being formatted to what i tell it.
my code:

dim date_now as date
date_now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")

So for example if the date/time is February 11 2015, 4:44:23pm it would be formatted as:

2015-02-11 04:44:23

Can somebody explaain where i have gone wrong?

regards
James

Recommended Answers

All 3 Replies

This worked fine

Dim date_now As Date
date_now = DateTime.Now
Debug.Print(date_now.ToString("yyyy/MM/dd HH:mm:ss"))

Yes this works, although it isnt what im after,
I need to date to have "-" dashes instead of "/" slashes.
and not to have the AM/PM at the end.

This:
2015-02-11 04:44:23
instead of:
2015/02/11 04:44:23 AM

I have solved this by using

Dim date_now As Date
date_now = DateTime.Now.Year & "-" & DateTime.Now.Month & "-" & DateTime.Now.Day & " " & DateTime.Now.Hour & ":" & DateTime.Now.Minute & ":" & DateTime.Now.second

Thanks for the help though :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.