-1

I'm looking for the equivalent of GETDATE() in SQL Server, but for ABAP Open SQL.

I have tried CURRENT_DATE, sy-date but with no success.

I've also tried CURDATE() and NOW(), but receive an error on specifically the open parenthesis for each.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48

1 Answers1

1

AFAIK there is no ABAP Open SQL function to get the current date or time on the database server. But you can pass the date and time from the application server using the global variables sy-datum and sy-uzeit. Example:

SELECT *
   FROM some_table
   WHERE due_date = @sy-datum
     AND due_time > @sy-uzeit
   INTO TABLE @DATA(gt_upcomming_today).

Note that sy-datum and sy-uzeit give you the date and time according to the timezone of the application server. If you want to convert those to the timezone of the user (according to the preferences of their user account), then there are and sy-datlo and sy-timlo. More information on the time-related fields of structure sy in the documentation.

Philipp
  • 67,764
  • 9
  • 118
  • 153
  • By the way, if you wonder why they called those `datum` and `uzeit` instead of `date` and `time`: Those variable names were nailed down when SAP was still developing in German. And now they can't change those without breaking millions of lines of legacy code. – Philipp Aug 22 '23 at 07:57