Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Conversion from Unix Epoch Time
#1
Hello Gintaras,
Hope all is well!
I have to convert from Unix Epoch Time to regular humna readable Date Time format.
eg. 1556915575 --> '5/3/2019 4:32 PM' 
I am not sure if this is already enabled by the DateTime functions in QM. 
I looked through and wasn't able to figure out myself.
A colleague gave me the code below for conversion. But before I went to figure out how to implement in QM, I thought I would check if this conversion not already supported by existing functions.

Thanks so much,
S
Code:
Copy      Help
 private string sUTCOffset = string.Empty;
private string sUNIXEpoch = "1-Jan-1970 00:00:00";
 
// Determine the daylightTime saving so the offset can be applied correctly.
TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
bool isDayLightSavingTime = tzi.IsDaylightSavingTime(DateTime.Now);
if (isDayLightSavingTime)
    sUTCOffset = " - 4/24";
else
sUTCOffset = " - 5/24";
 
// convert oracle unix date_time_created to datetime characters in c# codes
"TO_CHAR((TO_DATE('" + sUNIXEpoch + "','dd-mon-yyyy hh24:mi:ss') + (DOSR_STUDY.DATE_TIME_CREATED/60/60/24 ) " + sUTCOffset + " ), 'MM/DD/YYYY HH24:MI:SS') AS DATE_TIME_CREATED
 
// convert oracle unix date_time_created to datetime in c# codes
to_date('" + sUNIXEpoch + "','dd-mon-yyyy hh24:mi:ss') + (dosr_study.DATE_TIME_CREATED/60/60/24) " + sUTCOffset + " ) AS Date_Time_Created,sysdate - " + Minutes + "/(24*60), "


Messages In This Thread
Conversion from Unix Epoch Time - by stupomer - 05-06-2019, 06:11 PM
RE: Conversion from Unix Epoch Time - by Gintaras - 05-06-2019, 07:07 PM
RE: Conversion from Unix Epoch Time - by stupomer - 05-06-2019, 08:08 PM
RE: Conversion from Unix Epoch Time - by stupomer - 05-06-2019, 11:59 PM
RE: Conversion from Unix Epoch Time - by Gintaras - 05-07-2019, 04:58 AM
RE: Conversion from Unix Epoch Time - by stupomer - 05-07-2019, 05:38 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)