Former Member
Oct 17, 2013 at 06:58 PM

# Convert Number to Date & Time

55 Views

I need somebody to help me convert a number into date and time. My formula does get the date right but the time is off especially around midnight.

EXAMPLE

Date Created:- 20,131,015.00 (This should be converted to 10/15/13)

Time Created: - 1,949.00 (This should be 12:09:49 AM, but I'm getting 1:09:49 AM)

Time creared:- 449.00 (should be 12:04:49 AM, but I'm getting 4:04:49 AM)

Here is my code

//This function will take a date field AND a time field and give one Date/Time field

//V1 will be the date field, V2 is the time field

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 + MyDate;

local stringVar DayVar := MyDate + MyDate;

//Time Conversion

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));