Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

update -> date with time stamp

Posted on 2006-11-16
10
Medium Priority
?
2,167 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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 1200 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
 
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 800 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
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…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

885 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