This topic is locked

Error in query with NOW()....?

6/19/2009 6:19:58 AM
ASPRunnerPro General questions
S
stalbone author

Hi
Pls, because this query rise an error...?

Query is OK but in visual editor don't work....
SELECT

[Agenda_Attività ],

COUNT([Agenda_Attività ]) AS Totale,

Agenda_Anno,

Agenda_User

FROM AGENDA_atta

WHERE Agenda_Anno = year(now())

GROUP BY [Agenda_Attività ], Agenda_Anno, Agenda_User

Thank's
Stefano

J
Jane 6/19/2009

Stefano,
If it doesn't help zip your project file and database and open a ticket at http://support.xlinesoft.com sending files along with instructions on reproducing this error.

S
stalbone author 6/19/2009

Stefano,

If it doesn't help zip your project file and database and open a ticket at http://support.xlinesoft.com sending files along with instructions on reproducing this error.


Thank's Jane
But my project (I test AspRunner with a big project...) working with SQL2000...

How i send you data..?
Pls, my query-string, i think, is correct (work well in sql with sql2000) or not ?
Many Thanks for your help
Stefano

Sergey Kornilov admin 6/19/2009

As far as I know now() function doesn't exist in SQL Server.
I recommend to test your query in SQL Server first and then apply it in ASPRunnerPro.

S
stalbone author 6/19/2009

As far as I know now() function doesn't exist in SQL Server.

I recommend to test your query in SQL Server first and then apply it in ASPRunnerPro.


See image.... :-(

Sergey Kornilov admin 6/19/2009

{fn NOW()} and NOW() are not the same, right?
You can try to copy your SQL query from SQL Server management studio as is.

You can also use recommended getdate() function instead of now() which is not a part of T-SQL.

S
stalbone author 6/19/2009

{fn NOW()} and NOW() are not the same, right?

You can try to copy your SQL query from SQL Server management studio as is.

You can also use recommended getdate() function instead of now() which is not a part of T-SQL.


Sergey, you are right, I think by now about being fused...

<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=42026&image=1&table=forumreplies' class='bbc_emoticon' alt=':unsure:' />
Many thanks
Stefano

S
stalbone author 6/20/2009

{fn NOW()} and NOW() are not the same, right?

You can try to copy your SQL query from SQL Server management studio as is.

You can also use recommended getdate() function instead of now() which is not a part of T-SQL.


Sergey, sorry, but....
SELECT COUNT(Agenda_Attività ) AS Totale, Agenda_Attività , Agenda_User

FROM AGENDA_atta

WHERE (Agenda_Anno = YEAR(GETDATE()))

GROUP BY Agenda_Attività , Agenda_User

HAVING (Agenda_User = N'Signori')

This query working in SQL and, when i put it into "Edit sql" and press tab "Result", output is ok, but...

when i press tab "Query Designer", my query is trafomed in:
SELECT

[Agenda_Attività ] AS Totale,

[Agenda_Attività ],

Agenda_User

FROM AGENDA_atta

WHERE Agenda_Anno = YEAR(GETDATE())

GROUP BY [Agenda_Attività ], Agenda_User

HAVING Agenda_User = N'Signori'

and don't working....
Why?
Many.many thanks
Stefano




J
Jane 6/24/2009

What ASPRunnerPro version do you use?

S
stalbone author 6/25/2009

What ASPRunnerPro version do you use?


6.0 [build 766]
(Evalue...)

J
Jane 6/25/2009

Please zip and send your project and database to support@xlinesoft.com for investigation.

S
stalbone author 6/25/2009

Please zip and send your project and database to support@xlinesoft.com for investigation.


Sorry Jane but i working with sql2000 server and it's difficult to zip database...
However I have referred the query and this works very well.

Where is the error?

Mystery... <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=42172&image=1&table=forumreplies' class='bbcemoticon' alt='<<' />
Many thank's

Stefano
SELECT

AGENDA_atta.[Agenda_Attività ],

AGENDA_atta.Agenda_User,

COUNT(AGENDA_atta.[Agenda_Attività ]) AS Totale,

AGENDA_atta.Agenda_Anno,

dbo.AGENDA_Codici_Attivita.Descrizione_codice

FROM AGENDA_atta

INNER JOIN dbo.AGENDA_Codici_Attivita ON AGENDA_atta.[Agenda_Attività ] = dbo.AGENDA_Codici_Attivita.Codice_SAP

GROUP BY AGENDA_atta.[Agenda_Attività ], AGENDA_atta.Agenda_User, AGENDA_atta.Agenda_Anno, dbo.AGENDA_Codici_Attivita.Descrizione_codice

ORDER BY AGENDA_atta.Agenda_Anno DESC, dbo.AGENDA_Codici_Attivita.Descrizione_codice

C
clig 6/25/2009



Sorry Jane but i working with sql2000 server and it's difficult to zip database...
However I have referred the query and this works very well.

Where is the error?

Mystery... <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=42176&image=1&table=forumreplies' class='bbcemoticon' alt='<<' />
Many thank's

Stefano
SELECT

AGENDA_atta.[Agenda_Attività ],

AGENDA_atta.Agenda_User,

COUNT(AGENDA_atta.[Agenda_Attività ]) AS Totale,

AGENDA_atta.Agenda_Anno,

dbo.AGENDA_Codici_Attivita.Descrizione_codice

FROM AGENDA_atta

INNER JOIN dbo.AGENDA_Codici_Attivita ON AGENDA_atta.[Agenda_Attività ] = dbo.AGENDA_Codici_Attivita.Codice_SAP

GROUP BY AGENDA_atta.[Agenda_Attività ], AGENDA_atta.Agenda_User, AGENDA_atta.Agenda_Anno, dbo.AGENDA_Codici_Attivita.Descrizione_codice

ORDER BY AGENDA_atta.Agenda_Anno DESC, dbo.AGENDA_Codici_Attivita.Descrizione_codice


How about: "WHERE (DATEDIFF(year, AGENDA_atta.Agenda_Anno, GETDATE()) = 0)"
This will list for Agenda_Anno = this year
"WHERE (DATEDIFF(year, AGENDA_atta.Agenda_Anno, GETDATE()) = 1)" - Last year
"WHERE (DATEDIFF(year, AGENDA_atta.Agenda_Anno, GETDATE()) = 2)" - two years ago
So your query would look like this in MSSQL:
SELECT

[Agenda_Attività ] AS Totale,

[Agenda_Attività ],

Agenda_User

FROM AGENDA_atta

WHERE (DATEDIFF(year, AGENDA_atta.Agenda_Anno, GETDATE()) = 0)

GROUP BY [Agenda_Attività ], Agenda_User

HAVING Agenda_User = N'Signori'

  • provided "Agenda_Anno" is a datetime field

J
Jane 6/26/2009

Hi,
I wasn't able to reproduce this error.

I recommend you to not switch to Query Designer and edit SQL query manually.