• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2171
  • Last Modified:

update -> date with time stamp

Hi I have situation were I am trying to update as below were I am trying to update the create_ts as below. but I am lossing time stamp associated with that... how can I update with timestamp.

Update table_name
set
create_ts = sysdate-3
 where
staging_id in (XX1,XX2,XX3)
order by create_ts desc

Thanks
0
basirana
Asked:
basirana
  • 3
  • 2
  • 2
  • +3
2 Solutions
 
gvsbnarayanaCommented:
Hi,
try current_timestamp instead of sysdate.
HTH
Regards,
Badri.
0
 
Naveen KumarProduction Manager / Application Support ManagerCommented:
what is the data type of create_ts ?
0
 
Naveen KumarProduction Manager / Application Support ManagerCommented:
if is date data type, then i think time portion will be taken care of automatically with your update itself.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
DLyallCommented:
Try using select to_char(create_ts, 'ddmmyyyy hh24:mi') from table_name
0
 
DLyallCommented:
In case create_ts is not a date but a varchar, try

Update table_name
set
create_ts = to_char(sysdate-3, 'ddmmyyyy hh24:mi:ss')
 where
staging_id in (XX1,XX2,XX3)
order by create_ts desc

create_ts will have to be large enough to hold the date string
0
 
Mark GeerlingsDatabase AdministratorCommented:
Are you actually losing the time portion of the date in the column in the database, or is the tool you are using to display the values simply hiding the the time portion from you?

Please tell us:
1. the datatype of the "create_ts" column
2. which tool you use to view the results
3. your setting for NLS_DATE_FORMAT
0
 
awking00Commented:
What do you mean by "losing the timestamp associated with that ..."? The time portion is there, you may just need to have it displayed.
p.s. You don't use order by in an update statement
0
 
earth man2Commented:
Update table_name
set
create_ts = current-timestamp - interval '3' days
 where
staging_id in (XX1,XX2,XX3);

what do you hope to acheive with the order clause ?
0
 
earth man2Commented:
damn laptop keys are too small.
Update table_name
set
create_ts = current_timestamp - interval '3' days
 where
staging_id in (XX1,XX2,XX3);
0
 
earth man2Commented:
stupid nonintuitive sql...
Update table_name
set
create_ts = current_timestamp - interval '3' day
 where
staging_id in (XX1,XX2,XX3);
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now