Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am new to QlikView and have written a simple script to extract data from spreadsheets. While doing so, I have placed a simple if statement to compare two date variables and then execute a load if the condition is satisfield. For some reason the control is not executing the load even when the condition is satisfied. I am sure I have made a silly mistake, but not sure what it is. Please can any one help?
let xyz = Date(FileTime('Data3.xls'));
let abc = today();
if xyz = abc then
CoverDescription:
Mapping Load
CoverCode,
[Short Description]
FROM
Data3.xls
(biff, embedded labels, table is [Coverage-Data$]);
end if
Hi,
I guess the Date function is still keeping the time information, and when you call today() you have not the time, only the date. Use the num function to do the comparaison, and trace function to see what happen, then take the floor part of tha date, something like :
let xyz = floor(num(Date(FileTime('your file'))));
trace $(xyz);
let abc = num(today());
trace $(abc);
if xyz = abc then
trace ok;
else
trace not ok;
end if
Hi Tajdeenk,
Typically date/time functions are tricky in QV as sometimes the date comes out in d/m/y format, other times in UTC format (e.g. 45000).
Look in your variable overview in the front end if all your values come out the way they should. (Variable overview is CTRL+ATL+V). I think the today might be coming out in UTC format, hence you would need a date(today()) to format it in the3 right way.
Double check the values in the variable overview. The rest of your statement looks as it should be.
Hi,
I guess the Date function is still keeping the time information, and when you call today() you have not the time, only the date. Use the num function to do the comparaison, and trace function to see what happen, then take the floor part of tha date, something like :
let xyz = floor(num(Date(FileTime('your file'))));
trace $(xyz);
let abc = num(today());
trace $(abc);
if xyz = abc then
trace ok;
else
trace not ok;
end if
Hi CheenuJanakiram,
Thanks for your reply. I tried your suggestion and still it doesn't work. I can also see the variables containing exactly the same values n Debug mode.
Cheers,
Taj
Hi Renaud.Charlet,
Thanks for your suggestion. It is now working.
Many Thanks,
Taj.
Your welcome, happy to help you. Just keep in mind that a date is always a number, representing the number of days since 1900, with a decimal part for the time, it's easier to use thus number representation for comparisons rather that the real date format.