473,854 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DATEDIFF function in Oracle

17 New Member
for portability in SQL query ie a query written for one DB runs fine for other
i try to standardize our SQL queries as far as i can....
For finding the date difference we have:

DATEDIFF function in SQL Server
- operator in Oracle ...

i want to Sync this also how would i do that

i tried to create same name function in Oracle but having problem... of parameter type....what interval type should i take so that it works like SQL server DATEDIFF function.
Aug 13 '07 #1
4 112895
8,127 Recognized Expert Expert
If you want to write your own function well and good ,but simply if you wnat the different of 2 dates just use simple substration in oracle syntax.


select date1-date2 from dual;

if u wnat to write the function both the parameters should be of DATE data type and the return type can be number.
Aug 13 '07 #2
17 New Member
If you want to write your own function well and good ,but simply if you wnat the different of 2 dates just use simple substration in oracle syntax.


select date1-date2 from dual;

if u wnat to write the function both the parameters should be of DATE data type and the return type can be number.
let me more clearify my requirement....

What i actually want is to run the same query on Different DB, since this query is using Oracle - operator does'nt work as required in SQL Server.
select date1-date2 from dual;

What i want is if i write in SQL Server the following query
FROM myTable

This exactly without any change run fine in oracle ... this requires the DATEDIFF function in Oracle which is not there so i want create one for this ... but what about the first parameter of this function

please see detail of DATEDIFF at following link

but i cannot under stand what type of this parameter is day dd d

thanks for your co-operation
Aug 15 '07 #3
1 New Member
Did this ever get resolved I am fighting the exact same issue. And since Oracle does not support the ODBC TIMESTAMPDIFF function I can't quite get a handle on how to handle both databases with the same sql.
May 14 '09 #4
1 New Member
You should be able to get the number of days by subtract date1 - date2.


select name, date1-date2 days from customers

name days
bob 1
jane 5
rick 10

Hope this helps.
Jun 30 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

by: info | last post by:
Can some one show me how to use the datediff function where the dates are being supplied through an access db. For instance, a recordset would contain these fields: DateAssigned, DateDue, ProjectName, ProjectDetail, Class. The student enters a project name, then a date it was assigned and a date it is due...and other details about the project into the appropriate fields. The projects appear in a databound list box...when you click on a...
by: mcbill20 | last post by:
Hello all. I have a really basic question that I hope someone has a better answer for. I apologize in advance-- I know this is probably a really basic question but I am used to Oracle rathern than Access. I have a database where they customer wants to purge records from certain tables after three years. When I was asked to make the changes I originally thought this was an incredibly simple thing to do. I looked at the function list and...
by: Derrick | last post by:
I've included using Microsoft.VisualBasic, cranked up a VBCodeProvider, the only class I see in there, don't see DateDiff as a method though? Thanks in advance!! Derrick
by: reney | last post by:
I am trying to return the difference in minutes from a starttime and stoptime using the datediff function in a Web Project with VB.Net With: StartTime = 2/10/2006 8:46:03 PM EndTime = 2/10/2006 8:48:10 PM I am getting a return value of 1054586688 in the diff variable I tryed this same code in a Windows.Net Project and I get a return of 2 as I
by: KMEscherich | last post by:
Using Access '97 Hi there. I have a field that uses a DateDiff function to count the number of days between a DATE field and DATE(), is there a way to have the counter stop counting days when the FINISHED checkbox has been selected?? =DateDiff("d",,Date()) & " DAYS HAVE PASSED SINCE THE SRI SUBMITTED DATE" Thank you in advance for your assistance. K_Escherich
by: JenM | last post by:
Hi. I am a novice user. I am using the datediff function in a query. I am trying to calculate the number of week days between two dates. When I use "m" as the interval, the number of weeks is returned. When I use "d" or "y" as the interval, the number of days is returned. What kind of calculation can I add to the statement to only count the number of week days? Is this possible? I was thinking I might have to run a query on a query...
by: cmdolcet69 | last post by:
I'm trying to use the DateDiff function to calculate the difference whether a shift has been setup. when i run the code below with strFirstShiftEnd as a stringor date or datetime. I get an error Argument Date1 cannot be converted to type Date. an anyone clear this up. If DateDiff("n", Format(Now, "hh:mm AMPM"), Format(strFirstShiftEnd, "hh:mm AMPM")) <= 0 Then 'logout MsgBox("A shift change has occurred. You will be logged
by: cptcanada | last post by:
Hi All, I am getting an error saying that now() is not a reconized function in my datediff function would any one know why it is not being reconized? Thanks for the help ------------------------------------------------------------------------------------------------------------- USE Master EXEC xp_startmail 'outlook', 'drive8'
by: bandy | last post by:
Hi, I am using datediff() function to get difference between two dates. my code looks like, function dateDiff($dformat, $endDate, $beginDate) { $date_parts1 = explode($dformat, $beginDate); $date_parts2 = explode($dformat, $endDate); $start_date = gregoriantojd($date_parts1, $date_parts1, $date_parts1); $end_date = gregoriantojd($date_parts2, $date_parts2, $date_parts2);
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.