dbTalk Databases Forums  

How to set variable interval?

comp.databases.rdb comp.databases.rdb


Discuss How to set variable interval? in the comp.databases.rdb forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Frank Hung
 
Posts: n/a

Default How to set variable interval? - 10-26-2003 , 10:48 PM






Dear all,
I have wrriten an sqlmod, show part of them as below:


SELECT DISTINCT PROCESS_FLOW_ID FROM FCA_LOT
WHERE CAST(TIME_STAMP AS DATE ANSI)>=
CAST(CURRENT_TIMESTAMP AS DATE ANSI)- INTERVAL'60' DAY)

According to bove codes, i want to get data 60 days ago. But i hope this
time interval is variable but not fix. So i try to edit bellow codes:

...CAST(CURRENT_TIMESTAMP AS DATE ANSI)- INTERVAL :vat_day DAY)
However, above codes are syntax wrong. How should i do or any sql statement
to reach my object ?

Reply With Quote
  #2  
Old   
Richard Maher
 
Posts: n/a

Default Re: How to set variable interval? - 11-06-2003 , 01:46 AM






Hi Frank,

Try declaring the variable as data type INTERVAL eg:

declare :age interval year;
begin set :age =cast(50 as interval year); end;
select distinct last_name from employees WHERE CAST(BIRTHDAY AS DATE ANSI)
Quote:
=
(CAST(CURRENT_TIMESTAMP AS DATE ANSI)- :age);

Regards Richard Maher

Frank Hung <frank.hung (AT) qdi (DOT) com.tw> wrote

Quote:
Dear all,
I have wrriten an sqlmod, show part of them as below:


SELECT DISTINCT PROCESS_FLOW_ID FROM FCA_LOT
WHERE CAST(TIME_STAMP AS DATE ANSI)>=
CAST(CURRENT_TIMESTAMP AS DATE ANSI)- INTERVAL'60' DAY)

According to bove codes, i want to get data 60 days ago. But i hope this
time interval is variable but not fix. So i try to edit bellow codes:

...CAST(CURRENT_TIMESTAMP AS DATE ANSI)- INTERVAL :vat_day DAY)
However, above codes are syntax wrong. How should i do or any sql
statement
to reach my object ?



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.