Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
samuel_brierley
Creator
Creator

SQL Syntax Check

Hi all,

can someone please have a quick check of my SQL Syntax?

[Fault List]:

SQL SELECT *

FROM AFMS.dbo."All_Faults" WHERE "Raised_Time >"  $(Last_Updated_Date) "OR Reported_Time >" $(Last_Updated_Date);

store [Fault List] into Fault List.qvd;

thanks

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

I am assuming that the variable Last_Updated_Date contains the date in a text format recognised by the DB server as a date and can be implicitly converted to a datetime (or equivalent) SQL value.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

6 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

I think

[Fault List]:

SQL SELECT *

FROM AFMS.dbo.All_Faults WHERE Raised_Time > '$(Last_Updated_Date)' OR Reported_Time > '$(Last_Updated_Date)';

Store [Fault List] into [Fault List].qvd;

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

I am assuming that the variable Last_Updated_Date contains the date in a text format recognised by the DB server as a date and can be implicitly converted to a datetime (or equivalent) SQL value.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
samuel_brierley
Creator
Creator
Author

Hi Jonathan,

the last_Updated_Date is a timestamp as text in the database that Qlikview then converts to a date/TIme.and stores as a variable, i was assuming that if i then put my Where Clause using the variable it will still work, is this not the case?

jonathandienst
Partner - Champion III
Partner - Champion III

Yes, if the date in a text format recognised by the DB server as a date and can be implicitly converted to a datetime (or equivalent) SQL value.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
samuel_brierley
Creator
Creator
Author

ahh you werent wrong

SQL##f - SqlState: 22008, ErrorCode: 242, ErrorMsg: [Microsoft][SQL Server Native Client 11.0][SQL Server]The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

[Fault List]:

SQL SELECT *

FROM AFMS.dbo.All_Faults WHERE Raised_Time > '21/09/2015 12:07:44' OR Reported_Time > '21/09/2015 12:07:44'

samuel_brierley
Creator
Creator
Author

any ideas of whats gone wrong?

im thinking lunch then try and get to the bottom of this.