snowflake resource monitor creation start_timestamp format - Stack Overflow

I'm trying to create below resource monitor in snowflake which is throwing an error.CREATE OR REP

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 badges
Add a comment  | 

3 Answers 3

Reset to default 1

Timestamp 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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信