cancel
Showing results for 
Search instead for 
Did you mean: 

DaysBetween Master Data CreateDate and CurrentDate

0 Kudos

Dear Superusers,

I am currently trying to create a query so that I can see the number of days between the Master data creation date and current date, with below SQL, however, it doesn't work, would you help advice?

SELECT T0."ItemCode", T0."CreateDate", DAYS_BETWEEN (T0."CreateDate", CURRENT_DATE) "days between" FROM DUMMY FROM OITM

Thanks

monnie

0 Kudos

Ohh I got where I was wrong!

Should be as below

SELECT T0."ItemCode", T0."CreateDate", DAYS_BETWEEN (T0."CreateDate", CURRENT_DATE) "days between" FROM OITM T0

Accepted Solutions (1)

Accepted Solutions (1)

hdolenec
Contributor

Hi,

Is this for HANA or SQL? You didn't tag HANA, but DAYS_BETWEEN is HANA syntax.

Here is correct syntax for HANA. There are two problems:

  • FROM DUMMY is only used when selecting data that is not stored in tables, so you either use FROM DUMMY or FROM OITM, but not both
  • since you are selecting columns from T0, then you need to put T0 alias in FROM section for OITM table
SELECT T0."ItemCode", T0."CreateDate", DAYS_BETWEEN (T0."CreateDate", CURRENT_DATE)  "days between"  FROM OITM T0
0 Kudos

Super Thanks! hdolenec

Answers (0)