I've created a profile script which is taking an mbox parameter for 'Sign up date' (which is a text string: "yyyy-mm-dd"), and converting it into a number, whose digits are YYYYMMDD. The value returned in mboxTrace for my test account is ''2.0170713E7" (13th July 2017).
My hope is to then create an audience with criteria like "user.param IS GREATER THAN 20170728", or any others as and when they are needed. I.e., this is saying 'only target visitors who signed up after 28th July 2017'.
After testing, it doesn't appear to be working as expected. In some cases my content shows correctly, and others it doesn't, but it doesn't seem to correlate with numerical magnitude.
Is the 'greater than' criteria a sensible thing to use for user parameters, or are they always returned as text strings? If so, does anyone have an idea for an alternative solution?
Your code looks fine. So I would take a look at the data that is passed in your mbox.param('registrationdate') and validate that its always returning a date that you can use. Since its a string, if there are any letters or other characters in there, it could be causing an error. If the first character cannot be converted to a number, parseInt() returns NaN.
First you could try and run a regex to remove all non digits from the string before converting it to a number. Something like:
var dateText = year + month + day;
var date = parseInt(dateText);
Second idea, would be to do the date comparison within the profile script and return true if its greater than. Basically convert the string to a date and then do the comparison in JS. The limitation here would be that you would have a hard coded date and not a dynamic date that you could change for different campaigns within your test setup.
Can you post your full profile script code? Or if its long, at least the portion that the creates the date and converts the string to a number? And also, in your value "2.0170713E7" there is a period and "E7". Are these typos? What is the E7? I would think this is a string and not a number and therefore the greater than behaves differently with strings.