I need help converting a number to a Date & Time. The Date part works fine but I can never get the time to work correctly. My data is stored as a number
E.G
DATE:- 20,131,015.00
TIME:- 1,949.00.
[highlight #FCE94F]These two if converted to date time format should be 10/15/13 12;19:49 AM[/highlight]
Please find my code below
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);
local stringVar HrsVar := mid(Timehold,1,2);
local stringVar MinVar := Mid(Timehold,z-7+1,1)+mid(Timehold,z-6+1,1);
local stringVar SecVar :=mid(Timehold,z-5+1,2);
DateTime(ToNumber(YearVar), ToNumber(MonthVar), ToNumber(DayVar),
ToNumber(HrsVar), ToNumber(MinVar), ToNumber(SecVar));
E.G
DATE:- 20,131,015.00
TIME:- 1,949.00.
[highlight #FCE94F]These two if converted to date time format should be 10/15/13 12;19:49 AM[/highlight]
Please find my code below
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);
local stringVar HrsVar := mid(Timehold,1,2);
local stringVar MinVar := Mid(Timehold,z-7+1,1)+mid(Timehold,z-6+1,1);
local stringVar SecVar :=mid(Timehold,z-5+1,2);
DateTime(ToNumber(YearVar), ToNumber(MonthVar), ToNumber(DayVar),
ToNumber(HrsVar), ToNumber(MinVar), ToNumber(SecVar));