473,609 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datediff

2 New Member
Dear all, I a trying to select columns from two tables using a jointure with the condition that the request date in the first table should be in the same day as the collection date in the second table. Here is my sql script to explain more my issue:
Expand|Select|Wrap|Line Numbers
  1. select A.*, B.REQUEST_DATE, DATEDIFF(hh,to_char(B.REQUEST_DATE,'DD-MON-YY'), to_char(A.COLLECTION_DATE,'DD-MON-YY')) DIFF_DATE
  2. from V_DATA_OPERATIONAL_LATEST A 
  3. inner join V_PORT_RESET_CANDIDATES B 
  4. on A.line_id=B.line_id 
  5. where DATEDIFF(hh,to_char(B.REQUEST_DATE,'DD-MON-YY'), to_char(A.COLLECTION_DATE,'DD-MON-YY')) < 24 ; 
  6.  
However it doesn't seem to work.
Please help me figure out the issue.
Thank you very much.
Sep 18 '13 #1
3 1809
Rabbit
12,516 Recognized Expert Moderator MVP
Microsoft SQL Server doesn't have a to_char() function. Let me know which database you're actually using and I will move your question there.

But here are a few things I don't understand about your post. Why are you converting your date into a string if you're trying to get a DATEDIFF that expects the input to be a date, not a string?
Sep 18 '13 #2
sboufelj
2 New Member
thank you for your reply. I am using Oracle data base. and yes you are right, I shouldn't convert to a char but even when I write:
Expand|Select|Wrap|Line Numbers
  1. where DATEDIFF('hh', B.REQUEST_DATE, A.COLLECTION_DATE) < 24 ; 
  2.  
it doesn't work.
Thank you in advance.
Regards.
Sep 18 '13 #3
Rabbit
12,516 Recognized Expert Moderator MVP
Your thread has been moved to the Oracle forum.

You're typing the code tags wrong by the way, it's a forward slash, not a backward slash.

You're going to have to tell us what you mean by it doesn't work. That's very vague. We would need to know exactly what's not working, we need to see sample data and results along with expected results.
Sep 18 '13 #4

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

Similar topics

4
4092
by: CJM | last post by:
I have an ASP page that lists files and folders in a directory. I'm using a cookie to record the last time this page was visited, and I intend to show links that are created/modified from that date minus 30mins to the present... eg effectively new and modified files: If DateDiff("n", subfolder.DateLastModified, sLastVisit ) < 30 Then.... etc On my test machine this mechanism works OK, but on the live server (Win2k, IIS5) I get some...
8
5920
by: inamori | last post by:
I face that problems 07/01/2003 06/30/2006 ---------> it should be 3 01/01/2003 02/28/2005 --------->could i get 2 years and 2 months 01/01/2003 03/01/2005 --------->could i get 2 years and 2 months and 1
6
16506
by: Lofty | last post by:
Hi all. I have to write an app that interacts with mySQL (I really must have done some evil, evil stuff in a previous life to be landed with this!) I need to work out the difference in days between values in the database and the current date. "No problem," thought I , "I'll just use the SQL DATEDIFF command." Heh! Well, the user interface I'm using didn't even recognise DATEDIFF as being a function, so I decided to visit the mySQL...
1
7997
by: intl04 | last post by:
I'm trying to set up a query that will include a new field ('Days until completion') whose value is derived from the DateDiff function. I think I have the syntax correct but am not sure. Days until completion: DateDiff("d",,) is TODAY the appropriate syntax for today's date? Could the function/expression even be set up that way, or do I need to do something else to get 'days until completion'? (My Access manuals do not mention a TODAY...
4
11910
by: Paolo | last post by:
I am having some problem with a Year Function. I have form on which I have 4 field which indicate dates and an additional form which sums those dates: These are the fields: YEARS STARTINGDATE1 ENDINGDATE1 STARTINGDATE2
1
4976
by: PMBragg | last post by:
ORINGINAL Post >Thank you in advance. I'm trying to pull all inventory items from December >of the previous year back to 4 years for my accountant. I know this can be >done, but I'm drawing a blank. I've tried; > >DateDiff("y",-4,DateIn) and get errors > >Please any assistance would be greatly appreciated. >
7
15486
by: Adrian | last post by:
I hit on this problem converting a VB.NET insurance application to C#. Age next birthday calculated from date of birth is often needed in insurance premium calculations. Originally done using DateDiff in VB.NET which is only available in C# if you don't mind linking in Microsoft.VisualBasic.dll to your C# application. I wanted to avoid this so set about a pure C# solution which uses a combination of TimeSpan in whole days and the...
5
7230
by: sr | last post by:
Anyone know of a better way to simulate a datediff for C#, i.e., without referencing the VB.NET runtime? Only added the functionality that was needed for me so it is not the full implementation of the DateDiff in the VB.NET runtime. private int DateDiff( string Interval, DateTime Date1, DateTime Date2 ) { int intDateDiff = 0; TimeSpan time = Date1 - Date2;
6
7640
by: kevinjwilson | last post by:
I am trying to get the date difference between two dates but I don't want the function to include weekends in the calculation. Does anyone have an idea on how to make this work?
2
2760
by: muddasirmunir | last post by:
i am using vb 6 , i had place two datepicker in form now i want to calcuate differcen of month in two date for this i used the function datediff i had try it withh many syntax but getting error like datediff(mm,date1,date2) datediff(mmm,date1,date2) datediff(month,date1,date2) datediff("mm",date1,date2) datediff("mmm",date1,date2) datediff("month",date1,date2)
0
8573
Oralloy
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...
0
8547
jinu1996
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...
0
8406
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6062
isladogs
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...
0
5517
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();...
0
4026
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...
0
4091
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2535
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
1
1676
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.