cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
JulieSAppel
Level IV

Using Char to compare numeric and character values

Hi,

Is it possible to compare numeric and character values? 

I want to compare two columns (identical or different values). One column has a numeric date and one has a character date and as I need to compare only parts of it I want to use substring. The below script runs, but it doesn´t get me the correct result as all appears to be different (which is not the case). Am I using Char wrong?

 

If( Substr( Char( :Name( "Date/Time of Specimen Collection" ) ), 1, 10 ) == Substr( :Name( "Start Date/Time of Visit" ), 1, 10 ),
"identical",
"different"
)

I know I can change the format of "Date/Time of Specimen Collection" but I prefer not to as it will complicate other parts of my script.

 

Thanks in advance

2 ACCEPTED SOLUTIONS

Accepted Solutions
Craige_Hales
Super User

Re: Using Char to compare numeric and character values

Or even this:

You don't need substr for the yyy-mm-dd format; it already returns just the 10 characters you need.You don't need substr for the yyy-mm-dd format; it already returns just the 10 characters you need.

 

 

Craige

View solution in original post

JulieSAppel
Level IV

Re: Using Char to compare numeric and character values

Thanks a lot - I´ll give that a shot

View solution in original post

8 REPLIES 8
Craige_Hales
Super User

Re: Using Char to compare numeric and character values

To understand what's happening, make a temporary column with

Char( :Name( "Date/Time of Specimen Collection" ) )

as the formula. You'll probably need to use the format(...) function (instead of char(...)) to specify the exact date-time format you need to get all the values and separator characters correct. You can see the available format names when you use the column properties dialog and look at the format...date section.

Craige
JulieSAppel
Level IV

Re: Using Char to compare numeric and character values

I see your point. I cannot seem to get it right using format though.

Is there anyway of doing this without creating extra columns?

Craige_Hales
Super User

Re: Using Char to compare numeric and character values

Yes. What is the format of the character date?

Craige
JulieSAppel
Level IV

Re: Using Char to compare numeric and character values

In the attached table snip I´m trying to compare the date part of "Date/Time of Specimen Collection" column (numeric, yyy-mm-ddThh:mm:ss) with the "Start Date/Time of Visit" column (character, nominal)

 

Is there a function that allows jmp to see the numerical values as character (formatted as a date of course) so that I can use substring for the date part of it? 

Craige_Hales
Super User

Re: Using Char to compare numeric and character values

Using the format() function; the numeric date is in year-month-day for 7 February; the character format is in day/month/year.Using the format() function; the numeric date is in year-month-day for 7 February; the character format is in day/month/year.

Craige
Craige_Hales
Super User

Re: Using Char to compare numeric and character values

You might need this format:

the T format is an ISO standard.the T format is an ISO standard.

Craige
Craige_Hales
Super User

Re: Using Char to compare numeric and character values

Or even this:

You don't need substr for the yyy-mm-dd format; it already returns just the 10 characters you need.You don't need substr for the yyy-mm-dd format; it already returns just the 10 characters you need.

 

 

Craige
JulieSAppel
Level IV

Re: Using Char to compare numeric and character values

Thanks a lot - I´ll give that a shot