bfuchs
asked on
Convert string to number
Hi Experts,
I have the following code that gives users a message to update their browser if its not the latest one.
However since it can change from one minute to the next (as it just happened to chrome from 78 to 79), I would like to change the logic for something like, if Browser < 'Chrome 78.0'...
How can I accomplish that?
Thanks
I have the following code that gives users a message to update their browser if its not the latest one.
case when [@field:Browser]="Chrome 79.0" or [@field:Browser]="Safari 13.0" or [@field:Browser]="Firefox 71.0" or [@field:Browser]="InternetExplorer 11.0" or [@field:Browser]="Safari 13.0" then '' else 'Please update your browser! ' end
However since it can change from one minute to the next (as it just happened to chrome from 78 to 79), I would like to change the logic for something like, if Browser < 'Chrome 78.0'...
How can I accomplish that?
Thanks
You split the field on the blank and validate the Type and the version separatly.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Side note: Programming philosophy.
It is usually unnecessary to require the latest version of a browser. This introduces an artificial hurdle to users that annoys people no end, particularly so if the site worked yesterday with the previous version. Users may not be web wizards but they can figure this out.
Further, browser ident spoofing plugins make it impossible to verify a browser's actual version. Am I really on Windows 10 release 2491 using Firefox 93.4? Of course not, but my browser claims it because it seems to make some web sites happy to think that.
Better: Determine the last version of the browser that works correctly with the site, then suggest an update only if the user has a version which is older than that. And suggest it only once, then let them proceed anyway.
It is usually unnecessary to require the latest version of a browser. This introduces an artificial hurdle to users that annoys people no end, particularly so if the site worked yesterday with the previous version. Users may not be web wizards but they can figure this out.
Further, browser ident spoofing plugins make it impossible to verify a browser's actual version. Am I really on Windows 10 release 2491 using Firefox 93.4? Of course not, but my browser claims it because it seems to make some web sites happy to think that.
Better: Determine the last version of the browser that works correctly with the site, then suggest an update only if the user has a version which is older than that. And suggest it only once, then let them proceed anyway.
ASKER
Thank you!
ASKER
@Dr. Khlan,
Here at Caspio things unfortunate works differently...
We're experiencing a problem that users enter records w/o filling in all the required fields, and according to Caspio, this is due to none current browser version, and they refuse to support any version besides for the current...
Thanks,
Ben
It is usually unnecessary to require the latest version of a browser.
you really need to specify this is for Caspio not straight SQL. Otherwise you run into the same problem: You'll get SQL solutions that may not port easily to Caspio.
Here at Caspio things unfortunate works differently...
We're experiencing a problem that users enter records w/o filling in all the required fields, and according to Caspio, this is due to none current browser version, and they refuse to support any version besides for the current...
Thanks,
Ben
ASKER
@Netminder,
Actually that does not work for Safari.
I have the following formula field named Outdatedbrowser, with this formula.
And Safari 9.0 is showing 'No'
What can be done?
Thanks,
Ben
Actually that does not work for Safari.
I have the following formula field named Outdatedbrowser, with this formula.
case when ([@field:Browser] like 'Chrome%' and [@field:Browser]>='Chrome 78.0') or ([@field:Browser] like 'Safari%' and [@field:Browser]>='Safari 13.0') or ([@field:Browser] like 'Firefox%' and [@field:Browser]>='Firefox 71.0') or ([@field:Browser] like 'InternetExplorer%' and [@field:Browser]>='InternetExplorer 11.0') then 'No' Else 'Yes' end
And Safari 9.0 is showing 'No'
What can be done?
Thanks,
Ben
Didn't think about versions like 9 on the ascii sort.
You'll need to do the split.
Based on the Caspio docs, this should be close:
Fiddle:
https://dbfiddle.uk/?rdbms=sqlserver_2017&fiddle=f24aae52d58bedf51fc1eb7ce523265a
You'll need to do the split.
Based on the Caspio docs, this should be close:
with cte as (
select
substring(browser,1,charindex(' ',browser,1)-1) browserType,
convert(decimal(6,2),substring(browser,charindex(' ',browser,1)+1,len(browser))) browserVersion
from browsers
)
select browserType, browserVersion,
case when
(browserType = 'Chrome' and browserVersion<79.0) or
(browserType = 'Safari' and browserVersion<13.0) or
(browserType = 'Firefox' and browserVersion<71.0) or
(browserType = 'InternetExplorer' and browserVersion<11.0)
then 'Please update your browser! '
end badVersion
from cte
Fiddle:
https://dbfiddle.uk/?rdbms=sqlserver_2017&fiddle=f24aae52d58bedf51fc1eb7ce523265a
ASKER
Hi,
For some reason that didn't work in Caspio.
Therefore I applied similar formula.
Thanks,
Ben
For some reason that didn't work in Caspio.
Therefore I applied similar formula.
case when ([@field:Browser] like 'Chrome%' and [@field:Browser]>='Chrome 78.0') or ([@field:Browser] like 'Safari%' and CAST((Right([@field:Browser],(Len([@field:Browser])-Charindex(' ', [@field:Browser], 0)))) as FLOAT) >= 13) or ([@field:Browser] like 'Firefox%' and [@field:Browser]>='Firefox 71.0') or ([@field:Browser] like 'InternetExplorer%' and [@field:Browser]>='InternetExplorer 11.0') then 'No' Else 'Yes' end
Thanks,
Ben