August 4, 2014 at 4:03 am
SQLSeTTeR (7/31/2014)
Eirikur worked perfect. It did exactly what I needed it to do. Thanks again! 😀
What about 7/26/19?
declare @mycutoff date = '01/01/2020';
select [Date] = CONVERT(VARCHAR(10),CASE WHEN convert(datetime,'7/26/19',1) >= @mycutoff THEN DATEADD(YEAR,-100,convert(datetime,'7/26/19',1)) ELSE convert(datetime,'7/26/19',1) END,103)
August 4, 2014 at 5:49 am
I'm using:
DECLARE @CutOff DATE
SET @CutOff = '01/01/2016'
August 8, 2014 at 10:17 am
Ok, I just have to toss a wrench into the logic here.
Since we are talking about birthdays, what if the person is over 100 years old? This logic will fail.
August 8, 2014 at 10:47 am
What type of data is being stored in the database? What is the application it is supporting?
August 8, 2014 at 1:20 pm
DOB
August 8, 2014 at 2:31 pm
kherald69 (8/8/2014)
Ok, I just have to toss a wrench into the logic here.Since we are talking about birthdays, what if the person is over 100 years old? This logic will fail.
It will fail in the same manner as any other attempt to measure beyond the scale implied. This has to be adjusted in the way that majority of the set is covered.
😎
August 8, 2014 at 2:34 pm
Edit: Duplicate
August 8, 2014 at 3:15 pm
SQLSeTTeR (8/8/2014)
DOB
It is was obvious that one of the data elements is DOB but that didn't answer the question.
August 9, 2014 at 4:46 am
My apologies.
It's a DOB field being stored as a string. No application is pointing to this data.
Any help is much appreciated.
August 9, 2014 at 5:33 am
SQLSeTTeR (8/9/2014)
My apologies.It's a DOB field being stored as a string. No application is pointing to this data.
Any help is much appreciated.
First, do not store dates as strings. Use the appropriate data type, and since you appear to be on SQL Server 2008 that would be DATE.
So you have an entire database with one table storing DOBs, why?
Viewing 10 posts - 16 through 24 (of 24 total)
You must be logged in to reply to this topic. Login to reply