Solved

update -> date with time stamp

Posted on 2006-11-16
10
2,152 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
ID: 17957583
Hi,
try current_timestamp instead of sysdate.
HTH
Regards,
Badri.
0
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 17957716
what is the data type of create_ts ?
0
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 17957726
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
ID: 17957932
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
ID: 17958025
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 35

Expert Comment

by:Mark Geerlings
ID: 17958111
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 32

Expert Comment

by:awking00
ID: 17958113
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
ID: 17961921
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
ID: 17961927
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
ID: 17961939
stupid nonintuitive sql...
Update table_name
set
create_ts = current_timestamp - interval '3' day
 where
staging_id in (XX1,XX2,XX3);
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

911 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