i have a problem with this error i don't know why but i try many thing and search about it bout i didn't find any thing to solve this problem ( i want to make a query to calculate the age for the client auto in a column i have the Civil number for him like (286063001795) and i have some wrong civil No in my data ) the query is working good with little of data when i use it with my table gave me that error
UPDATE [dbo].[tabl]
set dob = CONVERT(date, convert(varchar(10), 17000000 + (CIVILIDD / 100000)))
select *, datediff(Month, dob, getdate())/12 as age, (CIVILIDD / 100000),17000000 + (CIVILIDD / 100000)
from [tabl]
Name_Arabic nvarchar(255) Checked CIVILIDD bigint Checked gender nvarchar(255) Checked NATIONALITY nvarchar(255) Checked dob date Checked
TRY_CONVERT
(also TRY_CAST, TRY_PARSE) - it tries to convert to a specific data type , and in case of error it returnNULL
. Add this function in your dataset and then search forNULL
learn.microsoft.com/en-us/sql/t-sql/functions/…WHERE dob IS NOT NULL AND TRY_CONVERT(date, <expression>) IS NULL;