Skip to Content
Author's profile photo vijaykumar ijeri

How to get abap date in HANA calculated column and calculate date difference

Hi All,

I had a requirement to find the date difference from the field LETZTZUG of table s032 and the current date.

Here the problem was getting the current date. I got the current date using now() function in calculated column functions.

The output of the now() was in yyyy-mm-dd hrs and second. I used date(now()) and got it as yyyy-mm-dd.

With this I was still not able to use daysbetween in order to find the duedate betwen LETZTZUG  and currentdate.

Then I used replace() function to eliminate ‘-‘ from the yyyy-mm-dd. So after that I could calculate the daysbetween().

This will overcome the problem of not having to_dats in calculated column.

/wp-content/uploads/2014/12/dd0_602925.png

/wp-content/uploads/2014/12/dd1_602787.png

/wp-content/uploads/2014/12/dd2_602788.png

And we have the netdue date here.

/wp-content/uploads/2014/12/dd3_602924.png

I hope this will be helpful for others. Experts please provide your suggestions on this.

Thanks & Regards,

Vijay

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Elegant and simple!

      Author's profile photo Lars Breddemann
      Lars Breddemann

      Ok, this surely works, but also shows that the SAP HANA documentation on those expressions should have been expanded.

      Nowadays (SPS 11/12) the need for graphical calc. views is decreasing and they meanwhile support SQL expressions.

      However, even with SPS 9 you could do things like

      dats_days_between("DATE_SAP", dats_from_daydate(now() ))

      or (other way round)

      daysbetween(dats_to_daydate("DATE_SAP"), now())

      No ugly SUBSTRING, no reliance on the output format of dates and way simpler to read.

      Author's profile photo Anshi sharma
      Anshi sharma

      suppose if I have date column in hana and I want to get date in that format like 1dec2019 should be 1st, 2 april should come like 2nd likewise, how can i get it?