?
Solved

how dateadd in oracle

Posted on 2005-03-13
8
Medium Priority
?
10,695 Views
Last Modified: 2011-08-18
how to get date 3 day after today in oracle?
0
Comment
Question by:aaaaaa
[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
  • +1
8 Comments
 
LVL 2

Assisted Solution

by:mkhaleelr
mkhaleelr earned 400 total points
ID: 13532481
-----if u r interested only in date part

select trunc(sysdate)+3 from dual;

---but if u want both date and time then

select to_char(sysdate + 3, 'dd-mm-yyyy hh24:mi') from dual




hope it helps


0
 
LVL 4

Author Comment

by:aaaaaa
ID: 13532494
i want it after add 3 day in date format
0
 
LVL 7

Expert Comment

by:Mehul Shah
ID: 13532496
The handling of Date column works the same in SQL as well as Oracle.  So as mkhaleelr mentioned you can just use + or - to add or subtract number of days from the current date.

You can use the SYSDATE Function in Oracle which is equivalent to GETDATE() of SQL Server and it returns current date and time. By default it will only display date if you want the time value than you will have to use to_char function along with Format strings to get the desired data/time format returned by your query

0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 4

Author Comment

by:aaaaaa
ID: 13532506
no.
to_char is change to string format.
i want is to_date? got this?

coz in ms sql, dateadd(mydate,3) still in date format, not string!
0
 
LVL 7

Accepted Solution

by:
Mehul Shah earned 1600 total points
ID: 13532525
By default any arithmatic operations on date column will give you a date output only so no need to use to_date also

select sysdate+3 from dual;

The above query will return a date value only i.e. 17-MAR-05.
0
 
LVL 11

Expert Comment

by:sujit_kumar
ID: 13532617
select sysdate+3 from dual


This will add 3 days to system's date. Suppose i want to add 3 days to the hire date of all the employees in emp table, then the query will be ,

select ename, hiredate+3 from emp;
0
 
LVL 2

Expert Comment

by:mkhaleelr
ID: 13532773
I hope u r using vb  :)


Private Sub Command1_Click()
Dim con As New Connection
Dim rs As New Recordset
Dim mydate As Date

con.Open "Provider=MSDAORA.1;User ID=scott;password=tiger;Data Source=orclDB;"
rs.Open "select sysdate+3 from dual", con
Do While Not rs.EOF
   mydate = rs.Fields(0)
   MsgBox Format(mydate, "d-mm-yyyy hh:mm:ss")
   rs.MoveNext
Loop
End Sub
0
 
LVL 2

Expert Comment

by:mkhaleelr
ID: 13532796
**********'pls ignore previuos post


I hope u r using vb  :)


Private Sub Command1_Click()
Dim con As New Connection
Dim rs As New Recordset
Dim mydate As Date

con.Open "Provider=MSDAORA.1;User ID=scott;password=tiger;Data Source=orclDB;"
rs.Open "select sysdate+3 from dual", con
Do While Not rs.EOF
   mydate = rs.Fields(0)

   MsgBox "Only Date: "   & Format(mydate, "dd-mm-yyyy")
   MsgBox "Date & Time: "   & Format(mydate, "dd-mm-yyyy hh:MM:ss")

   rs.MoveNext
Loop
End Sub
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Suggested Courses

777 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