getting last seven days records from sybase table

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
RAJARP
Participant
Posts: 147
Joined: Thu Dec 06, 2007 6:46 am
Location: Chennai

getting last seven days records from sybase table

Post by RAJARP »

Hi,
I have to get records which are updated in last 30 days.
one is a teradata table where i have used the following query

Code: Select all

select * from TERADATA.TABLE1 where upd_date between date-7 and date
and this query is executing fine.

the second one is a sybase table where i tried the following query

Code: Select all

select * from SYBASE.TABLE1  where upd_date between current_date-7 and current_date
but this query is giving me the following error while am trying view data

[IBM(DataDirect OEM)][ODBC Sybase Wire Protocol driver][SQL Server]Invalid column name 'current_date'.

so what is the sybase equivalent of

Code: Select all

where upd_date between date-7 and date
.

ps: I have never worked on sybase :-(
Thanks in advance.

Regards,
Raja R P
vinothkumar
Participant
Posts: 342
Joined: Tue Nov 04, 2008 10:38 am
Location: Chennai, India

Post by vinothkumar »

Try with getDate(). I found it through google only.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You have to find out how the particular database expresses current date. For example, in Oracle it's SYSDATE (if I recall correctly!). Consult a Sybase SQL manual.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

... or DBA. And yes, you recall correctly. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
RAJARP
Participant
Posts: 147
Joined: Thu Dec 06, 2007 6:46 am
Location: Chennai

Post by RAJARP »

hi all,
I have got one query
select * from SYBASE.TABLE1 where upd_date >=dateadd(dd,-7,getdate()) and upd_date <=getdate()


but yet to check it. any idea that this query would work?

Regards,
Raja R P
RAJARP
Participant
Posts: 147
Joined: Thu Dec 06, 2007 6:46 am
Location: Chennai

Post by RAJARP »

HI,
the below query is working. I have checked it. Thanks to all for your inputs

Code: Select all

select * from SYBASE.TABLE1 where upd_date >=dateadd(dd,-7,getdate()) and  upd_date <=getdate()
Regards,
Raja R P
Post Reply