Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Can we use substring function in CDS view where clause

Husain
Participant
0 Kudos

My requirement is to fetch the current year by using the system date variable in the CDS view.

I am using the substring function along with $session.system_date field in the where clause but it is not allowing me to use it.

Can someone guide me on how to use it in the where clause?

2 REPLIES 2

0 Kudos

Hi husainsd

please check below code you can able to understand,

define view ZK_I_DATE_FUNC as select from ZK_I_DATE_FUNCTIONS

{

Id,

Name,

StartDate,

EndDate,

//date functions

DATs_is_valid(StartDate) as s_Date1,

dats_is_valid(EndDate) as e_Date1,

dats_days_between(StartDate, EndDate) as betweenS,

dats_add_days(StartDate, 7, 'NULL') as ad_days,

dats_add_months(StartDate, 2, 'FAIL') as ADD_MONTHS,

DATS_ADD_DAYS(StartDate, 4, 'INITIAL') as option4,

DATS_ADD_DAYS(StartDate, 2, 'UNCHANGED') as option5

} where StartDate = $session.system_date

Husain
Participant
0 Kudos

Hi Kiran,

I need to extract the current year from the system.date. In the where clause something like

year= system.date+4?

Can we do this?