JLSG
JLSG

Reputation: 27

DATE and time SQL

I want to update the date and time using my computer time and date.

I want to be able when the information was manipulated from any user form his computer time. For instance, How can I make this function to get that information...I wrote TODAY with the function to_date(...) I wonder how can I do that? this is the SQL that I have so far.

UPDATE lora1app.ENG_PART_REV_JOURNAL_TAB 
set  TEXT ='from developer', DATE=to_date('TODAY','YYYYMMDDHH24:MI:SS') 
WHERE part_no ='147590'  and  
part_no in 
(SELECT part_no from lora1app.ENG_PART_REVISION_REFERENCE eprr  --We can use it to any OBJSATE 
 where eprr.OBJSTATE= 'Preliminary' and eprr.part_no='147590'  ) and TEXT is not null  
 and 
 PART_REV = (select max(PART_REV) from lora1app.ENG_PART_REVISION_REFERENCE eprr 
             where part_no ='147590' ) and 
 DT_CRE = (select max(DT_CRE) from lora1app.ENG_PART_REV_JOURNAL 
           where part_no ='147590'  )

One more time I want when this UPDATE runs ..I want the TIME and DATE when this happened... I am using SQL ORACLE DB

Upvotes: 0

Views: 71

Answers (2)

user330315
user330315

Reputation:

Use sysdate

UPDATE lora1app.ENG_PART_REV_JOURNAL_TAB 
  set TEXT = 'from developer', 
      DATE = sysdate
WHERE ...

If you want to be a bit more standard compliant, you can use current_timestamp

UPDATE lora1app.ENG_PART_REV_JOURNAL_TAB 
  set TEXT = 'from developer', 
      DATE = current_timestamp
WHERE ...

Upvotes: 2

ZyxwvuTJ
ZyxwvuTJ

Reputation: 21

Use SYSDATE for oracle, GETDATE() for sql server.

https://docs.oracle.com/database/121/SQLRF/functions207.htm#SQLRF06124

Upvotes: 2

Related Questions