Date Functions in Teradata

Date Functions in Teradata

I have teradata scripts

AND ADD_MONTHS('?StartDate',1)-1 BETWEEN A.CNTSTRT_DT AND COALESCE(A.CNTEND_DT, DATE) 

This script looks like it prompts for a date, then adds one month to that date. But I'm not clear on what the -1 does.

Additionally, I see that it compares the date to see if they are between the CNTSTRT_DT and CNTEND_DT, but what does the DATE do specifically?

3

1 Answer

The -1 is to substruct one day, for example the query:

select ADD_MONTHS(cast('2016/01/25' as date),1)-1

returns: 24/02/2016

Also, "Date" is a function which returns current date.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Elena Rostova
Author

Elena Rostova

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.