Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the following object with hard coded Month and Year

VB
objStreamWriter.WriteLine("March 2018""")


I declared a variable for currentdatetime as follows.
VB
Dim dtmCurrentDateTime As Date = Now


How do I change this hard coded March 2018 and instead use variable dtmCurrentDateTime.ToString("yyyy-MM-ddTHH:mm:ss") but without showing T in the time?
I want result to be like this 2018-04-06 09:53:48.
I do not want to display military time. So 01 PM should not be 13 00.

VB
objStreamWriter.WriteLine("March 2018""")


What I have tried:

I have tried the following which is hard coding the Month and year.
VB
objStreamWriter.WriteLine("March 2018""")


I also tried this but it's not working.
I am getting an error Comma,')', or a valid expression continuation expected.
VB
objStreamWriter.WriteLine("" dtmCurrentDateTime.ToString("yyyy-MM-ddTHH: mm : ss")"")
Posted
Updated 6-Apr-18 5:55am
v2

1 solution

See here: Formatting a DateTime for display - format string description[^] - it's exactly teh same for a stream.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900