Hi TD Gurus,
I am new to Teradata, I need to right a query which pull data from Januray to current date.If I enter tomarrow dates data should display from Jaunary to tomorrows date.
Please hel me to right a query.Data
Thanks in advance !!
you are not very informative with your question but try this:
select * from sys_calendar.calendar where extract(year from calendar_date) = extract(year from current_date) and calendar_date <= current_date ;
You can utilize TRUNC to get the first day of a year:
WHERE datecol BETWEEN TRUNC(CURRENT_DATE, 'YEAR') AND CURRENT_DATE
Hi Dieter, nice one
- is this a hidden feature?
15.1 documentation isn't mentioning DATE
Returns numeric_value truncated places_value places to the right or le of the decimal point.
Argument Types and Rules
Expressions passed to this function must have the following data types:
numeric_value = BYTEINT, SMALLINT, INTEGER, BIGINT, DECIMAL/NUMERIC, FLOAT/REAL/DOUBLE PRECISION, or NUMBER
places_value = NUMBER
you looked in the wrong place, there's another TRUNC(Date) in DateTime and Interval Functions and Expressions :-)
if you are looking for jan of this year till tomorrow then use below
and extract(year from datefield) = extract(year from current_date)
and datefield < current_date +1