Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Query fail Post Reply Post New Topic
Author Message
takugian
Newbie
Newbie


Joined: 17 Oct 2012
Online Status: Offline
Posts: 24
Quote takugian Replybullet Topic: Query fail
     Posted: 20 Nov 2012 at 11:04pm
Hi, guys! Are you okay?

See my query...

SELECT R.id_recomendacao, to_date(R.dt_fim_rec) - to_date(M.dt_inicio) AS PRAZO, to_date(CURRENT_DATE, 'DD/MM/YYYY') - to_date(R.dt_fim_rec) AS ATRASO

FROM TB_RECOMENDACAO R
INNER JOIN TB_MISSAO M ON (M.id_missao = R.fk_missao)
INNER JOIN TB_PROJETO P ON (P.id_projeto = M.fk_projeto)
WHERE P.fk_area = 222 AND R.sl_farol = 'vermelho'


Well, I need to make a stacked bar chart. Each "recomendação" has two date values, "PRAZO" and "ATRASO". This query works in SQL navigator, but in crystal, the second column (ATRASO) no. It returns "######".

I think it's because of "CURRENT_DATE". I tried to create a parameter with current date (to_date({?paramCurrentDate}, 'DD/MM/YYYY') - to_date(R.dt_fim_rec) AS ATRASO", but the problem continues...
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 21 Nov 2012 at 3:11am
which backend are you using?
 
to_date is not a SQL command...at least not T-SQL, and it's not a CR command, which would explain why it fails in the parameter.
 
Date(), CDate(), & DateValue() are valid CR commands to convert a string to a date.
 
Also, not knowing the backend, but I am suspicious of trying to subtract 2 dates from each other.  The standard way to find the difference in T-SQL is to use DateDiff
 
IP IP Logged
takugian
Newbie
Newbie


Joined: 17 Oct 2012
Online Status: Offline
Posts: 24
Quote takugian Replybullet Posted: 21 Nov 2012 at 3:42am
Originally posted by lockwelle



which backend are you using?
 
to_date is not a SQL command...at least not T-SQL, and it's not a CR command, which would explain why it fails in the parameter.
 
Date(), CDate(), & DateValue() are valid CR commands to convert a string to a date.
 
Also, not knowing the backend, but I am suspicious of trying to subtract 2 dates from each other.  The standard way to find the difference in T-SQL is to use DateDiff
 


I use SQL Navigator 5, but the db is Oracle. The query works on SQL Navigator very well. But it was not in crystal...

Now, I did it! I just removed 'DD/MM/YYYY'. This part was not necessary.

Thanks!!!
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum