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: 

CDS - Date calculation

Former Member
0 Kudos

Hi,

I'm trying to do som calculation with date type fields.

@AbapCatalog.sqlViewName: 'ZDEMOSDN'

@EndUserText.label: 'test'

define view ZDEMOSDN as select from aufk as a inner join afko as b

    on a.aufnr = b.aufnr

{

    key a.aufnr,

    a.erdat - a.idat2 as date2   

}

I'm getting the error messages:

Data type DATS is currently not supported in an arithmetic expression

Will this be supported in near future? Is there kind of workaround .

Regards,

Bart



4 REPLIES 4

christian_seitel
Participant
0 Kudos

There are functions like

dats_is_valid

dats_days_between

dats_add_days

dats_add_months

If they are not available yet in your current SP-release then there is no workaround as date-time calculations are very complex (just think of leap years or things like that)

0 Kudos

Thanks Christian. Unfortunately
not available, because of SP-release.

Regards,

Bart

0 Kudos

0 Kudos

Usage of a parameter could serve as workaround:

define view ...

  with parameters

    sydat : abap.dats @<Environment.systemField: #SYSTEM_DATE

  as select from svers

{

  dats_days_between( $parameters.sydat, $parameters.sydat ) as delta

}

or a join with another view (wrapping $session.system_date as column)

define view ...

  as select from svers

{

  $session.system_date as system_date

}