Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

What's wrong???

Hi all,

I try to load data from SQL.

LET dDate = date(MonthStart(today(),-13));

Tempo:

LOAD      

      Year(submitDateTime) as Year,

               Month(submitDateTime) as Month,

      Week(submitDateTime)& '-' & year(submitDateTime) as Week,

      'Q' & Ceil(Month(submitDateTime)/3)& '-' & year(submitDateTime) as Quarter,

      MonthName(Monthstart(submitDateTime)) as MYear,                                   // MMM YYYY

      QuarterName(QuarterStart(submitDateTime)) as QYYYY,*;

1:     

SQL SELECT * FROM dbo.aaa_690

WHERE date(submitDateTime)>=date('$(dDate)');

It should cut 13 months. But in this case it doesn't work. What do I miss?

Thanks in advanced,

1 Solution

Accepted Solutions
Not applicable
Author

LET dDateday = day(date(MonthStart(today(),-13)));

LET dDatemonth = num(month(date(MonthStart(today(),-13))));

LET dDateyear = year(date(MonthStart(today(),-13)));

Tempo:

LOAD      

      Year(submitDateTime) as Year,

         Month(submitDateTime) as Month,

      Week(submitDateTime)& '-' & year(submitDateTime) as Week,

      'Q' & Ceil(Month(submitDateTime)/3)& '-' & year(submitDateTime) as Quarter,

      MonthName(Monthstart(submitDateTime)) as MYear,                                   // MMM YYYY

      QuarterName(QuarterStart(submitDateTime)) as QYYYY,*;

Test:     

SQL SELECT * FROM dbo.aaa_690

where

(CAST((  STR( ( YEAR(submitDateTime) ) ) + '/' +  STR( MONTH(submitDateTime) ) + '/' +  STR( DAY(submitDateTime) )  ) AS DATETIME) ) >= CAST((  STR( ( $(dDateyear) ) ) + '/' +  STR( ($(dDatemonth)) ) + '/' +  STR(($(dDateday)) )  ) AS DATETIME);

Try that, I may have had an extra ')' in there.

View solution in original post

25 Replies
Not applicable
Author

What version SQL server are you on?

Anonymous
Not applicable
Author

or 9 or 11

Not applicable
Author

Not 2005 or 2008? I know for my data I had to reconvert the dates in SQL 2005 code so that they would work together:

((CAST((  STR( ( YEAR(changedate) ) ) + '/' +  STR( MONTH(changedate) ) + '/' +  STR( DAY(changedate) )  ) AS DATETIME) ) >= CAST((  STR( ( $(LastExecTimeyear) ) ) + '/' +  STR( ($(LastExecTimemonth)) ) + '/' +  STR(($(LastExecTimeday)) )  ) AS DATETIME)

Anonymous
Not applicable
Author

I use my condition for other project.

  CONCATENATE

  LOAD DISTINCT * FROM $(vQVD)\Historical.qvd (QVD)

  WHERE date(submitDateTime)>=date('$(dDate)');  

It work perfect. I try to SELECT use my condition. I see empty data.

Not applicable
Author

I do know loading from a QVD will not be the same as loading SQL. In loading from a QVD I believe it uses Qlikview formulas in the Where section. When doing a Select from SQL it uses the servers formula logic.

It was the same for me at first before I converted it where I did not get any errors, just saw no data.

Anonymous
Not applicable
Author

I'll try to save in QVD, then load it again.

Not applicable
Author

Use SET instead of LET.

Stephen

Not applicable
Author

Also in your WHERE statement remove the single quotes from '$(dDate)'

Anonymous
Not applicable
Author

I don't have problem when I load from QVD file. My syntax works.

When you load from SQL, it doesn't work.

Something wrong.