Date and time format in xls / csv conversion

1

I have a code that works, however I need help in the format of the date. In the conversion from xls to csv converts the date to mm / dd / yyyy and time in h: mm and I wanted it to be dd-mm-yyyy and the time in hh: mm. What do I need in my code?

example date and time conversion: 5/28/2018 0:15 and I needed you to do it this way: 28-05-2018 00:15

if WScript.Arguments.Count < 2 Then
    WScript.Echo "Please specify the source and the destination files. Usage: ExcelToCsv <xls/xlsx source file> <csv destination file>"
    Wscript.Quit
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
src_file = objFSO.GetAbsolutePathName(Wscript.Arguments.Item(0))
dest_file = objFSO.GetAbsolutePathName(WScript.Arguments.Item(1))
Dim oExcel
Set oExcel = CreateObject("Excel.Application")
Dim oBook
Set oBook = oExcel.Workbooks.Open(src_file)
oBook.SaveAs dest_file, 3
oBook.Close False
oExcel.Quit
Set objFile = objFSO.OpenTextFile(dest_file, 1)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, " ", ";")
Set objFile = objFSO.OpenTextFile(dest_file, 2)
objFile.WriteLine strNewText    
objFile.Close
    
asked by anonymous 19.06.2018 / 23:37

1 answer

0

Before

oBook.SaveAs dest_file, 3

do so:

oBook.Worksheets(0) _
    .Columns("letra da coluna que tem a data/hora a mudar") _
    .NumberFormat = "dd-MM-yyyy hh:mm"
    
20.06.2018 / 02:01