I'm trying to create below resource monitor in snowflake which is throwing an error.
CREATE OR REPLACE RESOURCE MONITOR LIMIT_1
WITH CREDIT_QUOTA = 100 FREQUENCY = MONTHLY
START_TIMESTAMP = '2025-03-31 00:00 IST'
NOTIFY_USERS = (SANGAM)
TRIGGERS ON 100 PERCENT DO NOTIFY;
The error is because of the value START_TIMESTAMP = '2025-03-31 00:00 IST'
The command works fine if I give START_TIMESTAMP = '2025-03-31 00:00' --> this takes UTC by default, but I want it to be set to IST.
What is the correct format for specifying IST.
I'm trying to create below resource monitor in snowflake which is throwing an error.
CREATE OR REPLACE RESOURCE MONITOR LIMIT_1
WITH CREDIT_QUOTA = 100 FREQUENCY = MONTHLY
START_TIMESTAMP = '2025-03-31 00:00 IST'
NOTIFY_USERS = (SANGAM)
TRIGGERS ON 100 PERCENT DO NOTIFY;
The error is because of the value START_TIMESTAMP = '2025-03-31 00:00 IST'
The command works fine if I give START_TIMESTAMP = '2025-03-31 00:00' --> this takes UTC by default, but I want it to be set to IST.
What is the correct format for specifying IST.
Share Improve this question asked Mar 21 at 9:40 curry_bcurry_b 335 bronze badges3 Answers
Reset to default 1Timestamp conversion to UTC string can be performed before CREATE RESOURCE MONITOR
:
SET date = TO_CHAR(CONVERT_TIMEZONE('Asia/Kolkata', 'UTC', '2025-03-31 00:00:00')
,'YYYY-MM-DD HH24:MI');
CREATE OR REPLACE RESOURCE MONITOR LIMIT_1
WITH CREDIT_QUOTA = 100
FREQUENCY = MONTHLY
START_TIMESTAMP = $date
NOTIFY_USERS = (SANGAM)
TRIGGERS ON 100 PERCENT DO NOTIFY;`
Try specifying the timestamp with a timezone component in IST:
START_TIMESTAMP = '2025-03-31 00:00:00 +0530'::TIMESTAMP_TZ
Full code:
CREATE OR REPLACE RESOURCE MONITOR LIMIT_1
WITH CREDIT_QUOTA = 100 FREQUENCY = MONTHLY
START_TIMESTAMP = '2025-03-31 00:00:00 +0530'::TIMESTAMP_TZ
NOTIFY_USERS = (SANGAM)
TRIGGERS ON 100 PERCENT DO NOTIFY;
You can first try to convert the time to UTC from Asia/Kolkata instead of IST
TO_CHAR(CONVERT_TIMEZONE('Asia/Kolkata', 'UTC', '2025-03-31 00:00'), 'YYYY-MM-DD HH24:MI')
which returns
2025-03-30 18:30
and then wrap the creation of resource monitor in an anonymous block
DECLARE
utc_time string;
BEGIN
utc_time:= TO_CHAR(CONVERT_TIMEZONE('Asia/Kolkata', 'UTC', '2025-03-31 00:00'), 'YYYY-MM-DD HH24:MI') ;
EXECUTE IMMEDIATE '
CREATE OR REPLACE RESOURCE MONITOR LIMIT_TEST
WITH CREDIT_QUOTA = 100
FREQUENCY = MONTHLY
START_TIMESTAMP = ''' || utc_time || '''
NOTIFY_USERS = (SAMHITA)
TRIGGERS ON 100 PERCENT DO NOTIFY';
END;
$$;
Upon querying resource monitors, LIMIT_TEST correctly shows START_TIME as 2025-03-30 18:30:00.000 +0000
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744363169a4570570.html
评论列表(0条)