DRAhmed Posted September 20, 2022 Report Share Posted September 20, 2022 CASE WHEN DATEDIFF(YEAR,[@field:master_year],GetDate()) >=2 THEN Cast([@field:test1]) AS specialist) ELSE Cast([@field:test1]) AS intern) END what is wrong with this calculation ? Quote Link to comment Share on other sites More sharing options...
0 sandy159 Posted September 21, 2022 Report Share Posted September 21, 2022 Hello @DRAhmed, You may want to try the following formula instead: CASE WHEN DATEDIFF(YEAR,[@field:master_year],GetDate()) >=2 THEN 'specialist' ELSE 'intern' END More about SQL functions can be found here:https://www.w3schools.com/sql/func_sqlserver_datediff.asphttps://www.w3schools.com/sql/func_sqlserver_cast.asp Quote Link to comment Share on other sites More sharing options...
0 ParkLoey Posted September 21, 2022 Report Share Posted September 21, 2022 Hi! Just to add a bit more info, I think the problem with the calculation was the result values. I believe CAST() function is used for converting a value to a specific datatype. CAST(expression AS datatype) Since specialist and intern aren't datatypes but I guess values you want to show, this will not be validated. In case statements, you can set the value of the result simply like the one provided above. You can check these links for more samples:https://howto.caspio.com/function-reference/#:~:text=Return-,Case,-Evaluates a list https://howto.caspio.com/datapages/reports/advanced-reporting/calculations-in-forms-and-reports/#:~:text=Birth. Learn more.-,Conditional Cases in Calculated Fields,-You can use I hope this helps DRAhmed 1 Quote Link to comment Share on other sites More sharing options...
0 ianGPT Posted June 28 Report Share Posted June 28 Hi, Just wanted to share the forum post below. You can use them as a reference for available syntaxes in Caspio's calculated field/value. https://howto.caspio.com/function-reference/ Quote Link to comment Share on other sites More sharing options...
Question
DRAhmed
CASE
WHEN DATEDIFF(YEAR,[@field:master_year],GetDate()) >=2
THEN Cast([@field:test1]) AS specialist)
ELSE Cast([@field:test1]) AS intern)
END
what is wrong with this calculation ?
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.