Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikView forum consolidation is complete. Labels are now required. LEARN ABOUT LABELS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Date comparison issue

Hi guys,

I got two dates

set d = 3/16/2014 4:26:55 PM

set d1 = 2014-03-16 16:26:55

I need to compare them.

I tried few things

if (Date($(d)) < Date($(d1)) // gives script line error

if ( $(d )< $(d1)) then // gives script line error

if ( (d )< (d1)) then // even though both dates are same it returns true.

Please help me with it.

Regards,

Saurabh

1 Solution

Accepted Solutions
hectorgarcia
Partner
Partner

SET ThousandSep=',';

SET DecimalSep='.';

SET MoneyThousandSep=',';

SET MoneyDecimalSep='.';

SET MoneyFormat='$#,##0.00;($#,##0.00)';

SET TimeFormat='hh:mm:ss';

SET DateFormat='YYYY-MM-DD';

SET TimestampFormat='YYYY-MM-DD hh:mm:ss[.fff]';

SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';

SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';

let d = num(timestamp#('3/16/2014 4:26:55 PM','M/D/YYYY h:m:s TT'));

let d1 = num('2014-03-16 16:26:55');

if $(d)<$(d1) then

let vCompare='d minor than d1';

exit script;

ENDIF

let vCompare='d Equal or bigger than d1';

exit script;

View solution in original post

3 Replies
hectorgarcia
Partner
Partner

hello, first of all i sugest you to unify the date format management according the format variables you have defined in your script

check this example

hectorgarcia
Partner
Partner

SET ThousandSep=',';

SET DecimalSep='.';

SET MoneyThousandSep=',';

SET MoneyDecimalSep='.';

SET MoneyFormat='$#,##0.00;($#,##0.00)';

SET TimeFormat='hh:mm:ss';

SET DateFormat='YYYY-MM-DD';

SET TimestampFormat='YYYY-MM-DD hh:mm:ss[.fff]';

SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';

SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';

let d = num(timestamp#('3/16/2014 4:26:55 PM','M/D/YYYY h:m:s TT'));

let d1 = num('2014-03-16 16:26:55');

if $(d)<$(d1) then

let vCompare='d minor than d1';

exit script;

ENDIF

let vCompare='d Equal or bigger than d1';

exit script;

View solution in original post

jagan
MVP & Luminary
MVP & Luminary

Hi,

Try like this

LET d = Timestamp(Timestamp#('3/16/2014 4:26:55 PM', 'M/D/YYYY h:m:s TT'))

LET d1 = Timestamp(Timestamp#('2014-03-16 16:26:55', 'YYYY-MM-DD hh:mm:ss'))

Now use this variables in script like this

if ( $(d )< $(d1))


Hope this helps you.




Regards,

Jagan.