1-- Create a copy with a recalculated age column2SELECT *,3       DATEDIFF(year, anon_date_of_birth, GETDATE()) AS Recalculated_Age4INTO Project_12345_Working..Demog5FROM Project_12345..Demography_Current6 7-- To refresh the age column later:8UPDATE Project_12345_Working..Demog9SET Recalculated_Age = DATEDIFF(year, anon_date_of_birth, GETDATE())
1with engine.connect() as conn:2    df = pd.read_sql("SELECT * FROM Project_12345..Demography_Current", conn)3 4# anon_date_of_birth is already a datetime column5df["Recalculated_Age"] = (6    pd.Timestamp.now().year - df["anon_date_of_birth"].dt.year7)8 9df.head()
1df <- dbGetQuery(conn, "SELECT * FROM Project_12345..Demography_Current")2 3df$Recalculated_Age <- as.integer(4  format(Sys.Date(), "%Y") ) - as.integer(format(df$anon_date_of_birth, "%Y")5)6 7head(df)