Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Fetch data from database for a particular year

Hi Experts,

I wanted to fetch the data from a database table named "table1" which were reported in year 2016

that is from 1st Jan,2016 to till date.

For this ,I am using the below query:

Select * From "table1";

where to_char("Reported_Date",'YYYY')='2016';

But I am getting an error like column not found whenever i put anything (any Function like to_date(), to_char(), Trunc()) before column Name.

Regards,

Anjali Gupta

7 Replies
nilapril2010
Contributor III
Contributor III

Try with the following logic -

Select * From Table1

Where Date(Date#(Reported_Date),'YYYY')='2016';

Regards

Nilanjan

Not applicable
Author

Hi Nilanjan,

I am still facing the same issue.

Regards,

Anjali Gupta

Not applicable
Author

Try:

Select * From Table1

Where year(YourDateField)=year(yearstart(today()));

Not applicable
Author

Hi Pravesh,

I tried this also, Any function before the dateField is showing me column not found error.

Regards,

Anjali Gupta

Anonymous
Not applicable
Author

Hi Anjali,

you need to write the column name exactlly, think that QlikView is case sensitive.

Then try this:

LOAD *

WHERE year(Reported_Date)=year(today());

SQL SELECT * FROM Table1;

Regards!!

Not applicable
Author

Have a look at your source data using a debug load (limit 100) to check the column formatting of the date field in question.

tyagishaila
Specialist
Specialist

TAB:

Load *,Date(Date#(Reporting_Date,'YYYY')) AS Year;

SQL Select * from table1;

Load *  Resident TAB where Year = '2016';

Drop Table TAB;