2020 Sep 07 3:15 PM
Derive the weekday based on the date.
Sunday = 1
Monday = 2
Tuesday = 3
Wednesday = 4
Thursday = 5
Friday = 6
Saturday = 7
if date is 12/31/2019 i.e Tuesday, output should be '3'
2020 Sep 07 6:20 PM
Something like that (ABAP CDS):
MOD( DATS_DAYS_BETWEEN( CAST( '00010102' AS abap.dats ) , yourdate ) , 7 ) + 1
NB: 0001/01/02 was a Sunday.
2020 Sep 09 9:06 AM
Hi Tendulkar,
Please check below sample CDS view definition which gives exactly the result what you are expecting
@AbapCatalog.sqlViewName: 'ZV_RND_VIEW'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'A Sample CDS View'
define view ZI_RND_VIEW
with parameters p_date: abap.dats
as select from I_CalendarDate {
//I_CalendarDate
CalendarDate,
CalendarYear,
CalendarMonth,
WeekDay
} where CalendarDate = $parameters.p_date;
the weekday is the field which gives you the number of the day
Thanks
Pavan Bhamidipati
2020 Sep 14 10:15 AM
Hi Pavan,
Will check this code as well. However, the above code mentioned by Sandro is working as expected.
Thanks for your help!
2020 Sep 13 7:39 PM
2020 Sep 14 10:13 AM
Hello Sandra,
Greetings.
Sorry for replying late.
I implemented the above code and it worked. Thanks for your help!