ABAP Open SQL - What is the function to return current date?

448 views Asked by At

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.

1

There are 1 answers

1
Philipp On

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.