Solved

update -> date with time stamp

Posted on 2006-11-16
10
2,155 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
capture vmstat info and insert it into an oracle table 31 93
oracle numeric condition check 4 50
format dd/mm/yyyy parameter 16 60
oracle query 4 31
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
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…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

710 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