I’ve got various date formats originating from Windows and Mac which have proved problematic and would like to change these date formats as of when they are read.
The existing code I’m attempting to amend already performs some date corrections from the problematic into the desired format dd/mm/yyyy.
Below are the problematic formats:
dd.mm.yyyy
dd.mm.yy
dd-mmm-yy
d/m/yy
yyyy-mm-dd,
dd mmmm yyyy
Below is the code:
dim filename, filenameA as string
dim datesep As integer
filename = "23.4.15"
System.DebugLog("Filename content: " + filename)
filenameA = filename + "-" +"05:49:00"
System.DebugLog("FilenameA: " + filenameA)
filename = filename +"05:49:00"
System.DebugLog("Before correction: " + filenameA)
If InStr(filename,"/")>0 then
datesep=InStr(filename,"/")
System.DebugLog("datesep == " + Str(datesep))
filename.ch(datesep)=""
end if
If InStr(filename,"/")>0 then
datesep=InStr(filename,"/")
System.DebugLog("datesep == " + Str(datesep))
filename.ch(datesep)=""
end if
If InStr(filename,":")>0 then
datesep=InStr(filename,":")
System.DebugLog("datesep == " + Str(datesep))
filename.ch(datesep)=""
end if
If InStr(filename,":")>0 then
datesep=InStr(filename,":")
System.DebugLog("datesep == " + Str(datesep))
filename.ch(datesep)=""
end if
If InStr(filename,".")>0 then
datesep=InStr(filename,".")
System.DebugLog("datesep == " + Str(datesep))
filename.ch(datesep)=""
end if
If InStr(filename,".")>0 then
datesep=InStr(filename,".")
System.DebugLog("datesep == " + Str(datesep))
filename.ch(datesep)=""
end if
If InStr(filenamea,"/")>0 then
datesep=InStr(filenamea,"/")
System.DebugLog("datesep == " + Str(datesep))
filenamea.ch(datesep)="-"
end if
If InStr(filenamea,"/")>0 then
datesep=InStr(filenamea,"/")
System.DebugLog("datesep == " + Str(datesep))
filenamea.ch(datesep)="-"
end if
If InStr(filenamea,"/")>0 then
datesep=InStr(filenamea,"/")
System.DebugLog("datesep == " + Str(datesep))
filenamea.ch(datesep)="-"
end if
If InStr(filenamea,"/")>0 then
datesep=InStr(filenamea,"/")
System.DebugLog("datesep == " + Str(datesep))
filenamea.ch(datesep)="-"
end if
If InStr(filenamea,":")>0 then
datesep=InStr(filenamea,":")
System.DebugLog("datesep == " + Str(datesep))
filenamea.ch(datesep)="-"
end if
If InStr(filenamea,":")>0 then
datesep=InStr(filenamea,":")
System.DebugLog("datesep == " + Str(datesep))
filenamea.ch(datesep)="-"
end if
If InStr(filenamea,":")>0 then
datesep=InStr(filenamea,":")
System.DebugLog("datesep == " + Str(datesep))
filenamea.ch(datesep)="-"
end if
If InStr(filenamea,":")>0 then
datesep=InStr(filenamea,":")
System.DebugLog("datesep == " + Str(datesep))
filenamea.ch(datesep)="-"
end if
If InStr(filenamea,".")>0 then
datesep=InStr(filenamea,".")
System.DebugLog("datesep == " + Str(datesep))
filenamea.ch(datesep)="/"
System.DebugLog(filename.ch(datesep))
end if
If InStr(filenamea,".")>0 then
datesep=InStr(filenamea,".")
System.DebugLog("datesep == " + Str(datesep))
filenamea.ch(datesep)="/"
end if
System.DebugLog("After correction: "+ filenamea)
I need help with two bits of the code:
The first is to understand what [quote]filenamea.ch(datesep)="-"[/quote] means? does
Secondly below I’ve played around with the code to attempt correcting the first problematic date format I mentioned above i.e. dd.mm.yyyy or dd.mm.yy to dd/mm/yyyy.
This is how do it:
If InStr(filenamea,".")>0 then
datesep=InStr(filenamea,".")
System.DebugLog("datesep == " + Str(datesep))
filenamea.ch(datesep)="/"
end if
How do you advise I attempt correcting this date format i.e. dd-mmm-yyy