Hello,
The problem is very simple and I am able to work it out, but somehow theere seems to be a bug in the output. So wondering if there is an error in my formula?
I have a JMP table with a time Col in the format as (mm/dd/yyyy h:m:s AM/PM)
dt << New Column("DATE_FLAG", Character,Nominal,
Formula(If(
Abbrev Date( :Name( "TIME_COL@ABC" ) ) <=
Abbrev Date( 22Jul2020 ),
"before",
"after"
)));
Now finally in my updated table I am getting the DATE_FLAG Column and before/after values. But some of the values/rows) which should be before say the dates are before2th July 2020 are still labelled as after? The rest of the rows are labelled as expected.
So what is wrong? Do I have to specify the date time format? If so how can I ?
I think I figured out the problem, but need some help with that:
The Abbrev Date comparison is comparing the two Character Date strings and that's why when 07/04/2020 10:12:34 AM is converted to 07/4/2020 when compared with 07/22/2020 is giving after instead of before.
How can I fix this?
Thanks
There's no need to do any conversion to anything else to compare date values.
Just use a date constant in your comparison by specifying the date in ddMonYYYY format:
dt << New Column( "DATE_FLAG",
Character,
Nominal,
Formula( If( :Name( "TIME_COL@ABC" ) <= 22Jul2020, "before", "after" ) )
);
Read more about date values:
Using dates, times, datetimes and durations in JMP