For tests proposes, I need to get the current system date.

On Oracle we could use: SELECT SYSDATE FROM DUAL


On DB2 we would use: Select current timestamp from sysibm.sysdummy1

I see this question was asked. How to Get the Current System Time using SOQL

However the response did not answer the question completely.

I have same question.

Notice for Oracle it uses generic DUAL table for the from. Notice for SQL Server you do not even have to specify a from table to get the date returned. Notice from DB2 it uses a generic sysdummy1 table for the from.

I would like to know how to use the select to get the sysdate returned in salesforce.

This needs to be generic way to get the system date returned without specifying a from table.

  • 3
    why does this have to be done with soql? why won't the apex solution as answered in the referenced question work?
    – cropredy
    Oct 16, 2019 at 17:33

1 Answer 1


There isn't an equivalent SOQL query; SOQL is not SQL, and is intentionally simple to avoid many of the problems of SQL languages (e.g. SQL injection to perform DML, etc). Instead, Salesforce provides the getServerTimestamp API call. The documentation says:

Use getServerTimestamp() to obtain the current system timestamp from the API. You might do this if, for example, you need to use the exact timestamp for timing or data synchronization purposes. When you create() or update() an object, the API uses the system timestamp to update the CreatedDate and LastModifiedDate fields, respectively, in the object.

The getServerTimestamp() call always returns the timestamp in Coordinated Universal Time (UTC) time zone. However, your local system might automatically display the results in your local time based on your time zone settings.

Of course, if you're in Apex Code, use DateTime.now() or another equivalent already covered in the other answer.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .