If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > sysdate - 1

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-19-03, 17:42
Naweed Naweed is offline
Registered User
 
Join Date: Nov 2003
Posts: 76
Red face sysdate - 1

how do I do a
update sysdate -1
on a table column and still keep the date formatt
'MM/DD/YYYY HH24:MIS'.

this is killing me.
I keep getting the following format after the "update sydate - 1"
DD-MON-YY

it works fine for dual but not any other table.

help!!
Reply With Quote
  #2 (permalink)  
Old 12-20-03, 03:15
Bart71 Bart71 is offline
Registered User
 
Join Date: Oct 2003
Location: Germany - Stuttgart
Posts: 14
Hi,

which oracle version you have? On 9I (9.2.0.4) it works.

Maybe you can try:

to_date(sysdate-1,'DD.MM.RRRR')
Reply With Quote
  #3 (permalink)  
Old 12-22-03, 08:47
edwinjames edwinjames is offline
Registered User
 
Join Date: Dec 2003
Posts: 74
Re: sysdate - 1

Quote:
Originally posted by Naweed
how do I do a
update sysdate -1
on a table column and still keep the date formatt
'MM/DD/YYYY HH24:MIS'.

this is killing me.
I keep getting the following format after the "update sydate - 1"
DD-MON-YY

it works fine for dual but not any other table.

help!!
-Are you inserting into another date column?
if YES then you just need to change the way your are displaying your date.

SQL> alter session set nls_date_format = 'MM/DD/YYYY HH24:MIS';

Session altered.

SQL> select sysdate-1 from dual;

SYSDATE-1
-------------------
12/21/2003 13:46:42

If you want to convert the date in the format 'MM/DD/YYYY HH24:MIS' to a character field then do the following

SQL> select to_char(sysdate-1,'MM/DD/YYYY HH24:MIS') from dual;

TO_CHAR(SYSDATE-1,'
-------------------
12/21/2003 13:45:34

I hope this helps

Edwin
Reply With Quote
  #4 (permalink)  
Old 12-22-03, 10:20
shelva shelva is offline
Registered User
 
Join Date: Nov 2003
Location: Rotterdam, Netherlands
Posts: 127
If you want to make the changes permanent (date format)
the you have to change it in INIT.ORA
NLS_DATE_FORMAT='dd/mm/yyyyHH24:MIS'
Reply With Quote
  #5 (permalink)  
Old 12-22-03, 15:26
Naweed Naweed is offline
Registered User
 
Join Date: Nov 2003
Posts: 76
Thank you.
How about sutracting 5 minutes from the current time.
Reply With Quote
  #6 (permalink)  
Old 12-23-03, 04:03
edwinjames edwinjames is offline
Registered User
 
Join Date: Dec 2003
Posts: 74
select sysdate - 1/24 from dual; = today minus 1 hour

so

select sysdate - (1/24/60)*5 from dual

today / 24 = 1 hour / 60 = 1 minute * 5 give five minutes


regards

edwin
Reply With Quote
  #7 (permalink)  
Old 01-07-04, 16:07
Naweed Naweed is offline
Registered User
 
Join Date: Nov 2003
Posts: 76
Thank you all
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On