Adrian
Adrian

Reputation: 5681

ERROR when using getDate() in oracle to update rows

I have a table with a column called STREAM_TIME of DATE type.
I'm trying to update all rows for that column to today's date. The database used is oracle.

My query:

update bns_bess_messages SET stream_time=getDate();

Oracle comes back with this error:

SQL Error: ORA-00904: "GETDATE": invalid identifier
00904. 00000 -  "%s: invalid identifier"

How can I update STREAM_TIME to today's date?

Thanks

Upvotes: 5

Views: 14655

Answers (3)

Pranay Rana
Pranay Rana

Reputation: 176946

getDate() is part of sql server function for oracle use one of below

make use of

select current_date
from dual;

update bns_bess_messages SET stream_time=current_date

or

The built-in function SYSDATE returns a DATE value containing the current date and time on your system. For example,

select to_char(sysdate, 'Dy DD-Mon-YYYY HH24:MI:SS') as "Current Time"
from dual;

update bns_bess_messages SET stream_time=sysdate

Upvotes: 5

Holger Brandt
Holger Brandt

Reputation: 4354

Oracle uses sysdate instead of getDate()

update bns_bess_messages SET stream_time=sysdate;

Upvotes: 5

Andrew Logvinov
Andrew Logvinov

Reputation: 21851

You can do it the following way:

update bns_bess_messages set stream_time = trunc(sysdate);

Or if you want to get the exact time:

update bns_bess_messages set stream_time = sysdate;

To check you can use the following query:

select sysdate from dual;

Upvotes: 7

Related Questions