cancel
Showing results for 
Search instead for 
Did you mean: 

BODS: How to get current date time in UTC+0 with BODS function

0 Kudos
7,631

How to get current date time in UTC+0, by simply any BODS function?

Found that there is BODS function "local_to_utc", but it is not used, as local time zone, or job server time zone is unknown in my scenario.

Date time should not be get from database, as it is highly dependent on DB connection.

SQL('MYSQL_DB', 'SELECT UTC_TIMESTAMP');

Accepted Solutions (0)

Answers (5)

Answers (5)

How about using sysdate() to get current system date time, then use local_to_utc()?

0 Kudos

I just tried with below script. But it printed out date time in UTC+1, instead of UTC+0.

Second parameter (<timezone of the input with UTC offset>) in function local_to_utc is unspecified, as time zone is unknown for my scenario.

#Script for demo

$V_CURRENT_UTC_DATE_TIME = local_to_utc(sysdate());

print('$V_CURRENT_UTC_DATE_TIME=' || to_char($V_CURRENT_UTC_DATE_TIME, 'yyyy.mm.dd hh24:mi:ss'));

I want current date time in UTC+0.

Can it be done?

0 Kudos

Is there any suggestion for this question?

0 Kudos

Is there any suggestion for below question?

How to get current date time in UTC+0 with BODS function

0 Kudos

Glad to know "$V_CURRENT_UTC_DATE_TIME = local_to_utc(sysdate(), 'UTC-04:00');"
can return current date time in UTC+0 due to job server located in time zone UTC-4:00.

For day light saving, I don't see a better way other than manually change it to UTC-03:00.
I didn't find any function to pick up time change due to day light saving. Sorry

0 Kudos

Try this:

$V_CURRENT_UTC_DATE_TIME = local_to_utc(sysdate(), 'UTC+00:00');

See if this result is what you want.

0 Kudos

Below script does NOT return current date time in UTC+0.

$V_CURRENT_UTC_DATE_TIME = local_to_utc(sysdate(), 'UTC+00:00');Below script return current date time in UTC+0, for job server that located in time zone UTC-4:00.

$V_CURRENT_UTC_DATE_TIME = local_to_utc(sysdate(), 'UTC-04:00');

But it is not preferred way, as i have to modify the 2nd parameter in this function to UTC-3:00, when day light saving is started.