简体   繁体   中英

Report Today minus 1 day

need help with this query DB2 IBM

SELECT 
  ABALPH AS Kunde,
  SDLITM AS Artikel,
  SDDSC1 AS Beschreibung,
  SDSOQS AS Menge, date(digits(decimal(SDIVD+1900000,7,0))) AS Invoice,
  decimal(SDUPRC/10000,15,2) AS Einzelpreis,
  decimal(SDAEXP/100,15,2) AS Gesamtpreis,
  SDDOCO AS Dokument,
  AIAC01 AS Region

Now my question is, how can I get the today date minus 1 day?

Thank you so much

have test it with ADD_DAYS doesn´t work.

I do not see the point in your query where a date is referenced but your query seems incomlete anyways because join contions are missing.

In general you get todays date with current date and you get yesterday with current date - 1 day

Check out this query:

SELECT current date, current date - 1 day 
FROM sysibm.sysdummy1

Per the DB2 documentation , ADD_DAYS is valid with negative numbers for previous days. See example 4 on that page. So usage like this should have worked:

  ADD_DAYS(DATE(...), -1) 

or

  ADD_DAYS(CURRENT_DATE, -1)

You should post your specific attempted usage of it and the error that is reported when you try it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM