Hello,
I could get UTC time from database by returning the value as a string. Now a small issue in arriving the milliseconds that we could not multiply the 1000 in a single row, but by multiplying it three times (by 10 each), we could get the correct value.
**************************************************
LongLong ll_return_milli
Long ll_days, ll_seconds
Long ll_hours, ll_min, ll_sec, ll_micro
Datetime ld_basedatetime
Date ld_system_date
ld_basedatetime = Datetime('1970/01/01 00:00:00')
Select today_now
into :as_system_datetime
From (Select Cast(now() at time zone 'utc' as varchar) as today_now) a;
ld_system_date = Date(Mid(as_system_datetime, 1, 10))
ll_hours = Long(Mid(as_system_datetime, 12, 2))
ll_min = Long(Mid(as_system_datetime, 15,2))
ll_sec = Long(Mid(as_system_datetime, 18,2))
ll_micro = Long(Mid(as_system_datetime, 21))
ll_days = DaysAfter(Date(ld_basedatetime), ld_system_date)
// Multiplying all in one single line gives wrong value
// So the last 1000 is multiplied in 3 rows below
//ll_return_milli = ll_days * 24 * 60 * 60 * 1000 -> Wrong value
ll_return_milli = (ll_days * (24 * 60 * 60))
ll_return_milli = ll_return_milli * 10
ll_return_milli = ll_return_milli * 10
ll_return_milli = ll_return_milli * 10 -> Correct value
ll_return_milli += (ll_hours * 60 * 60 * 1000)
ll_return_milli += (ll_min * 60 * 1000)
ll_return_milli += (ll_sec * 1000)
ll_return_milli += ll_micro
Return ll_return_milli
*************************************************
Don't know why (ll_days * 24 * 60 * 60 * 1000) doesn't give the correct result, when ll_days = 18661. {haven't checked with lower values}
But multiplying 1000 in three times (each time by 10), gives the correct result.
Happiness Always
BKR Sivaprakash