March 5, 2020 at 8:45 am
Hi
After I create a Named Calculation,I can't Explore Data. I get Error:
TITLE: Microsoft Visual Studio
------------------------------
Input string was not in a correct format.
------------------------------
BUTTONS:
OK
------------------------------
March 6, 2020 at 9:10 am
Thanks for posting your issue and hopefully someone will answer soon.
This is an automated bump to increase visibility of your question.
March 7, 2020 at 3:45 pm
I can't help you with your Visual Studio problem because I don't use it. I can tell you, though, that your formula for age in years is incorrect simply because of the way DATEDIFF works. You need to use something like the following...
ALTER FUNCTION [Util].[AgeInYears]
(
@StartDT DATETIME, --Date of birth or date of manufacture or start date.
@EndDT DATETIME --Usually, GETDATE() or CURRENT_TIMESTAMP but
--can be any date source like a column that has an end date.
)
RETURNS TABLE WITH SCHEMABINDING AS
RETURN
SELECT AgeInYears =
DATEDIFF(yy, @StartDT, @EndDT)
- CASE --If anniversary date hasn''t happended yet this year, subtract 1.
WHEN DATEADD(yy, DATEDIFF(yy, @StartDT, @EndDT), @StartDT) > @EndDT
THEN 1
ELSE 0
END
;
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply