rubamushtaq Posted November 14, 2012 Share Posted November 14, 2012 Hi, I have been reading all the answers on calculating date difference but I could not get it yet. Can any one tell me how can I get the days from the difference of two timestamps fields in ireport.I would like to show my sql query, 1. Nvl((Select Max(c.finish_date) from code_det cd, os_historystep c where cd.module_code = 'RPT' ),'') appReciveddt,-- This is first date field. 2. Nvl((Select Max(c.start_date) from code_det cd, os_historystep c where cd.module_code = 'RPT' ) ),'') creditristdt,--This is second date field. From table..... I need to get the days=creditristdt - appRecivedd. I want the "days" as a field in sql .I do not want to store the days in variable. Kindly tell me how to acheive this? Ruba Link to comment Share on other sites More sharing options...
mgeise Posted November 14, 2012 Share Posted November 14, 2012 From Here: http://www.w3schools.com/sql/func_datediff_mysql.asp MySQL DATEDIFF() Functionhttp://www.w3schools.com/images/up.gif MySQL Date FunctionsDefinition and UsageThe DATEDIFF() function returns the time between two dates.Syntax DATEDIFF(date1,date2)Where date1 and date2 are valid date or date/time expressions.Note: Only the date parts of the values are used in the calculation.ExampleThe following SELECT statement: SELECT DATEDIFF('2008-11-30','2008-11-29') AS DiffDatewill result in this: DiffDate 1 ExampleThe following SELECT statement: SELECT DATEDIFF('2008-11-29','2008-11-30') AS DiffDatewill result in this: DiffDate -1 Link to comment Share on other sites More sharing options...
rubamushtaq Posted November 14, 2012 Author Share Posted November 14, 2012 The very functions of DateIff always shows an error that DATEDIFF is invalid identifier. Kindly note that I am using oracle sql developer.I wonder would that funtion be supported?.I have checked the type of feilds ,they are valid dates and they get printed but whenever I take difference ,I get an error.Anyhow I really do appreciate your response. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now