0

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

2
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by Gobble45
1

This worked fine

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

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

0

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 :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.