I need help converting a string to a date time. My string in the format 20,121,109 for the date and 3,325 for the time. This should convert to 11/9/2012 with a time of 0:33:25. I'm using the formula below to convert it but when the time is between midnight and 1 my times are all messed up. Somebody please help.
Function (numberVar v1, numberVar v2)
//Date Conversion
local stringVar MyDate := CStr(v1);
local stringVar YearVar := MyDate[1 to 2] + MyDate[4 to 5];
local stringVar MonthVar := MyDate[6] + MyDate[8];
local stringVar DayVar := MyDate[9] + MyDate[10];
//Time Conversion
local numbervar MyTimeNum:= Int(v2);
Local stringvar MyTimeStr := cstr(MyTimeNum);
if MyTimeNum<100000 then MyTimeStr := "0"+MyTimeStr;
Replace(MyTimeStr,",","",1);
//fill in array
local stringVar TimeHold := MyTimeStr;
local stringVar Allzeros := "00000000";
Replace(TimeHold,".","",1);
local numberVar z := Length(Timehold);
//if z<8 then TimeHold := Mid(Allzeros,1,(8-z))+Timehold;
local stringVar HrsVar := mid(Timehold,1,2);
local stringVar MinVar := Mid(Timehold,z-8+1,1)+mid(Timehold,z-6+1,1);
local stringVar SecVar :=mid(Timehold,z-5+1,2);
//if isNumeric(MonthVar) and isNumeric(YearVar) and isNumeric(DayVar) and isNumeric(TimeString) then
DateTime(ToNumber(YearVar), ToNumber(MonthVar), ToNumber(DayVar),
ToNumber(HrsVar), ToNumber(MinVar), ToNumber(SecVar));
Function (numberVar v1, numberVar v2)
//Date Conversion
local stringVar MyDate := CStr(v1);
local stringVar YearVar := MyDate[1 to 2] + MyDate[4 to 5];
local stringVar MonthVar := MyDate[6] + MyDate[8];
local stringVar DayVar := MyDate[9] + MyDate[10];
//Time Conversion
local numbervar MyTimeNum:= Int(v2);
Local stringvar MyTimeStr := cstr(MyTimeNum);
if MyTimeNum<100000 then MyTimeStr := "0"+MyTimeStr;
Replace(MyTimeStr,",","",1);
//fill in array
local stringVar TimeHold := MyTimeStr;
local stringVar Allzeros := "00000000";
Replace(TimeHold,".","",1);
local numberVar z := Length(Timehold);
//if z<8 then TimeHold := Mid(Allzeros,1,(8-z))+Timehold;
local stringVar HrsVar := mid(Timehold,1,2);
local stringVar MinVar := Mid(Timehold,z-8+1,1)+mid(Timehold,z-6+1,1);
local stringVar SecVar :=mid(Timehold,z-5+1,2);
//if isNumeric(MonthVar) and isNumeric(YearVar) and isNumeric(DayVar) and isNumeric(TimeString) then
DateTime(ToNumber(YearVar), ToNumber(MonthVar), ToNumber(DayVar),
ToNumber(HrsVar), ToNumber(MinVar), ToNumber(SecVar));