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

Weekday and Time function - response (2) by dnoeth

$
0
0

There's no built-in function for weekday, but besides a calendar you might do a simple calculation, e.g. this will return monday as 1:
REPLACE FUNCTION day_of_week(cdate DATE)
RETURNS BYTEINT
SPECIFIC day_of_week_date
RETURNS NULL ON NULL INPUT
CONTAINS SQL
DETERMINISTIC
COLLATION INVOKER
INLINE TYPE 1
RETURN ((cdate - DATE '0001-01-01') MOD 7) + 1  
If you can't create SQL UDFs simply use the calculation as-is.
 
There's only one recommended qway to write a time literal: TIME '18:00:00'
Similar for dates: DATE '2013-07-21' and timestamps: TIMESTAMP '2013-07-21 18:00:00'
 
Dieter


Viewing all articles
Browse latest Browse all 14773

Trending Articles



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