One of common calculations, we have to do in ETL is calculating age of the person from the date attribute And this is how I have calculated Age of the person. Select BirthDate , CASE WHEN Month ( GetDate ()) < Month ( c . [BirthDate] ) THEN DateDiff ( yy , c . [BirthDate] , GetDate ()) - 1 WHEN Month ( GetDate ()) = Month ( c . [BirthDate] ) AND Day ( GetDate ()) < Day ( c . [BirthDate] ) THEN DateDiff ( yy , c . [BirthDate] , GetDate ()) - 1 ELSE DateDiff ( yy , c . [BirthDate] , GetDate ()) ...
Comments
Post a Comment