Add minutes to timestamp

Database
Enthusiast

Add minutes to timestamp

Quite new to Teradata and finding a bit difficulty handling date/timestamp.
i know it would we quite simple but unable to find relevant links over net

How to add 10 minutes to current timestamp in TD?

+ any link explaining this topic would be really good.
5 REPLIES
Enthusiast

Re: Add minutes to timestamp

SEL CURRENT_TIMESTAMP + INTERVAL '10' MINUTE
Enthusiast

Re: Add minutes to timestamp

Thanks , it is working fine when run on bteq , but when i try to put it into procedure .. it fails to get compile. pl advise

***************************
SPL1027:E(L12), Missing/Invalid SQL statement'E(3707):Syntax error, expected something like a string or a Unicode character literal between the 'interval' keyword and the word 'v_in1'.'

***************************
replace procedure dev.ts_test (in v_in integer)
dynamic result sets 1
P1: begin
declare v1 timestamp;
declare v_in1 varchar(10);

declare c1 cursor with return only for
select current_timestamp , v1 ;

set v_in1 = trim(cast ( v_in as varchar(10))) ;

set v1 = current_timestamp + interval v_in1 minute ;

open c1;

end p1 ;
Enthusiast

Re: Add minutes to timestamp

why you are declaring v_in1 as varchar(10); you simply need to cast input paramete v_in as INTERVAL MINUTE in your expression
Enthusiast

Re: Add minutes to timestamp

i was using the Integer input variable initially, but was getting the same syntax error.
I assume teradata expects minutes in ' '

Enthusiast

Re: Add minutes to timestamp

just change this

set v1 = current_timestamp + CAST(v_in AS interval minute) ;