cancel
Showing results for 
Search instead for 
Did you mean: 

Get the month , year and day from given date

Former Member
0 Kudos

Hi Experts,

I am trying to do the leftstring,rightstring functions for given date to get the month and year columns.

like below,

leftstr("ZZSTUFFINGDATE",5)

but I am not getting proper results.

please suggest in this case.

Thanks.

Best Regards,

Edukondalu Konakanchi

Accepted Solutions (1)

Accepted Solutions (1)

lbreddemann
Active Contributor
0 Kudos

Guys, what is up with all that string converting/cutting?

Why does nobody simply use the component () (respectively dats_component() ) function instead?

- Lars

Former Member
0 Kudos

>Guys, what is up with all that string converting/cutting?

Good point !

Honestly, I just answered the question without thinking seeing function not used as it should.

Perfect example of "how not to..." 

Former Member
0 Kudos

Hi,

I am using this component(STUFFINGDATE,3) but getting an error

attribute is missing in node level.

the M_dimension_month has been seen but it didnt work.

Please advise proper solution for this.

Thanks.

Br,

Ed

lbreddemann
Active Contributor
0 Kudos

Your reply doesn't work either.

What's the error message you get? What is the problem with using any of the options?

Please state your problems properly.

- Lars

former_member210482
Active Participant
0 Kudos

Hi Ed,

Can you elaborate your problem regarding m_dimension_month..? Just join your table to sap_date field and derive the month..

Since joins are costlier, you can go with the suggestion of Lars.

Regards,

Safiyu

former_member185132
Active Contributor
0 Kudos

Please do read the documentation. You need to use the Year, Month and Day functions

Here's the standard doc for the Month function, you can get the rest there as well.

https://help.sap.com/saphelp_hanaone/helpdata/en/20/e544ea75191014b8209a9fc217ce0e/content.htm

Answers (4)

Answers (4)

former_member210482
Active Participant
0 Kudos

Hi Ed,

Please make use of m_time_dimension table to derive it. You can find this table in sys_bi schema. join your date field to this table and derive required fields..

Cheers,

Safiyu

Former Member
0 Kudos

Not getting proper result ?

You have to convert to string before using string function

for instance:

leftstr( string("ZZSTUFFINGDATE") ,3)

Hope this helps

Former Member
0 Kudos

Hi

Move your date into a character based field, in this example we name it lv_date

If your date looks like this: 20150219

You can derive the values as follows: (Define the variables accordingly as character based)

lv_year = lv_date+0(4).   - Result 2015

lv_month = lv_date+4(2). - Result 02
lv_day = lv_date+6(2) - Result 19

Then you can do with the variables whatever you like, after they've been split

Regards

Arden

Former Member
0 Kudos

Hi,

Try formatting the date before using before using the leftstr.

You can also use substr function after formatting the date.

=Substr([V_DATE];3;7)

Thanks,

Shakthi Raj Natarajan.