Solved

update -> date with time stamp

Posted on 2006-11-16
10
2,151 Views
Last Modified: 2012-06-27
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
Comment
Question by:basirana
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 8

Expert Comment

by:gvsbnarayana
Comment Utility
Hi,
try current_timestamp instead of sysdate.
HTH
Regards,
Badri.
0
 
LVL 28

Expert Comment

by:Naveen Kumar
Comment Utility
what is the data type of create_ts ?
0
 
LVL 28

Expert Comment

by:Naveen Kumar
Comment Utility
if is date data type, then i think time portion will be taken care of automatically with your update itself.
0
 
LVL 6

Expert Comment

by:DLyall
Comment Utility
Try using select to_char(create_ts, 'ddmmyyyy hh24:mi') from table_name
0
 
LVL 6

Assisted Solution

by:DLyall
DLyall earned 300 total points
Comment Utility
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 34

Expert Comment

by:Mark Geerlings
Comment Utility
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
 
LVL 31

Expert Comment

by:awking00
Comment Utility
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
 
LVL 22

Accepted Solution

by:
earth man2 earned 200 total points
Comment Utility
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
 
LVL 22

Expert Comment

by:earth man2
Comment Utility
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
 
LVL 22

Expert Comment

by:earth man2
Comment Utility
stupid nonintuitive sql...
Update table_name
set
create_ts = current_timestamp - interval '3' day
 where
staging_id in (XX1,XX2,XX3);
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  â€¦
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now