I have a database that is storing dates in millisecond epoch timestamp format. I cannot figure out how to take this format and turn it into a "calendar" date/time.

Actually I can get the calendar date - just can't get the time to work like it should.

For instance, 1305211842916 should be equal to 5/12/11 9:50:42AM [CST]. I can get the date of 5/12, but the hours don't work out right.

Here's what I've got thus far:
WhilePrintingRecords;
NumberVar StartTotalsec := {A_STARTTIMETS};
NumberVar StartDays := truncate(StartTotalsec/86400);
NumberVar StartHours := truncate(Remainder(StartTotalsec,86400)/3600);
Numbervar StartMinutes := truncate(Remainder(StartTotalsec,3600)/60);
Numbervar StartSeconds := Remainder(StartTotalsec,60);
Totext (StartDays, '##')+'$'+
Totext (StartHours, '00')+':'+
Totext (StartMinutes, '00')+':'+
Totext (StartSeconds, '00');