Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Syntax error: expected something between '(' and the 'current_date' keyword. - response (5) by dnoeth

$
0
0

When you're on TD13.10 you can use a SQL UDF, otherwise simply use the calculation:

REPLACE FUNCTION WEEK_BEGIN(cdate DATE)
RETURNS DATE
SPECIFIC week_begin_DA
RETURNS NULL ON NULL INPUT
CONTAINS SQL
DETERMINISTIC
COLLATION INVOKER
INLINE TYPE 1
RETURN 
  cdate-(((cdate - DATE '0001-01-01')) MOD 7)

This returns the begin of the week, so

SELECT WEEK_BEGIN(DATE)-1

simply subtract one:
 


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>