-
date
The following code returns the filedate as:
i.e.
"152009"
"1062009"
...
How can I alter the code to show "152009" as "01052009" notice the 0
Dim fileCreateDate As Date = File.GetCreationTime(strSourcePath)
Dim strImportDate As String = fileCreateDate.Day.ToString() & "" & fileCreateDate.Month.ToString() & "" & fileCreateDate.Year.ToString()
Thanks
-
Re: date
The ToString accepts a format string as a parameter...
Code:
Dim strImportDate As String = fileCreateDate.Day.ToString("00") & "" & fileCreateDate.Month.ToString("00") & "" & fileCreateDate.Year.ToString("0000")
-tg
-
Re: date
You don't need to split the date up like that just to format it though. You can do it in 1 ToString call.
Code:
Dim fileCreateDate As Date = File.GetCreationTime(strSourcePath)
Dim strImportDate As String = fileCreateDate.ToString("ddMMyyyy")
-
Re: date
-
Re: date
To make searching easier, doing yyyyMMdd is a lot easier to read.