- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Using Char to compare numeric and character values
Thanks a lot - I´ll give that a shot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Using Char to compare numeric and character values
Yes. What is the format of the character date?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Using Char to compare numeric and character values
You might need this format:
the T format is an ISO standard.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Using Char to compare numeric and character values
Thanks a lot - I´ll give that a shot