Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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,
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.
What version SQL server are you on?
or 9 or 11
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)
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.
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.
I'll try to save in QVD, then load it again.
Use SET instead of LET.
Stephen
Also in your WHERE statement remove the single quotes from '$(dDate)'
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.