Page 1 of 1

Current date in Teredata

Posted: Wed Apr 27, 2011 12:59 pm
by sagar deshmukh
Hi,

Could you please suggest me how can I get current date if I am executing below Query in Teradata Enterprise stage.

Query :

SELECT
PREV_YR_DT,DATE
FROM cldr


This query works fine in SQL editor but when I am executing in Teradata enterprise stage its failing.

Is there any way to get Current Date through SQL?

Thanks
Sagar

Posted: Wed Apr 27, 2011 1:07 pm
by MarkB
Maybe try CURRENT_DATE instead of DATE???

Posted: Wed Apr 27, 2011 1:14 pm
by sagar deshmukh
Tried that, its not working.

Posted: Wed Apr 27, 2011 2:32 pm
by throbinson
This works in 7.5 in the Enterprise Stage
SELECT CURRENT_DATE AS DATE1 FROM <tablename>.

You'd need a column defined as DATE1. I called it DATE1 varchar(50).

Posted: Wed Apr 27, 2011 3:52 pm
by sagar deshmukh
Hi Thanks this solution is working.... but again i have issue when i am putting a where clause as


where CLDR_DT = CURRENT_DATE - 1

for this clause it fails.

Posted: Thu Apr 28, 2011 4:03 am
by sagar deshmukh
Any can help?

Posted: Thu Apr 28, 2011 5:35 am
by pandeesh
Sagar,

please try this and let me know

where CLDR_DT= (select CURRENT_DATE)-1

Posted: Thu Apr 28, 2011 5:35 am
by throbinson
This doesn't sound like either a Teradata or DataStage 7.5 problem...
This SQL within the Teradata Enterprise Stage has no issues at all.
SELECT CURRENT_DATE - 1 AS DATE1 from <table_name>
WHERE CURRENT_DATE - 1 = CURRENT_DATE -1

Posted: Thu Apr 28, 2011 6:56 am
by chulett
sagar deshmukh wrote:Any can help?
All you've said so far is "it is failing" or "it failed"... why not post the error message(s) so we have some dang idea why it is failing? :?

Since the SQL is apparently valid, have you checked with your official support provider? Perhaps it is a known issue...

Posted: Thu Apr 28, 2011 11:23 pm
by pandeesh
Sagar,

have you got the solution for this?