When I try to display the date in Excel in the format dd/mm/yyyy hh , I get it, the date looks as expected:
10/20/2016 17
10/20/2016 18
In the case above, I display the date and time as follows:
nRowDate = 1 For nDay = 20 To 21 For nHour = 0 To 23 If (nDay < 10) Then Str = "0" + CStr(nDay) + "/" + MonthNumber + "/" + Year + " " Else Str = CStr(nDay) + "/" + MonthNumber + "/" + Year + " " End If If (nHour < 10) Then Str = Str + "0" + CStr(nHour) Else Str = Str + CStr(nHour) End If Date_Array(nRowDate) = Str nRowDate = nRowDate + 1 Cells(nRowDate, 1).Value = Format(Str, "dd/mm/yyyy hh") Next nHour Next nDay But I can't get the date in dd/mm/yyyy hh:mm:ss format, the output looks like this:
10/20/2016 00:00:00
10/20/2016 00:00:10
Here is the code:
nRowDate = 1 For nDay = 20 To 21 For nHour = 0 To 23 For nMinutes = 0 To 60 For nSec = 0 To 5 If (nDay < 10) Then Str = "0" + CStr(nDay) + "/" + MonthNumber + "/" + Year + " " Else Str = CStr(nDay) + "/" + MonthNumber + "/" + Year + " " End If If (nHour < 10) Then Str = Str + "0" + CStr(nHour) Else Str = Str + CStr(nHour) End If If (nMinutes < 10) Then Str = Str + ":0" + CStr(nMinutes) Else Str = Str + ":" + CStr(nMinutes) End If If (nSec = 0) Then Str = Str + ":00" Else Str = Str + ":0" + CStr(nSec * 10) End If Date_Array(nRowDate) = Str nRowDate = nRowDate + 1 Cells(nRowDate, 1).Value = Format(Str, "dd/mm/yyyy hh:mm:ss") Next nSec Next nMinutes Next nHour Next nDay Where did I go wrong? ..
