-- Create a copy with a recalculated age columnSELECT *,
DATEDIFF(year, anon_date_of_birth, GETDATE()) AS Recalculated_Age
INTO Project_12345_Working..Demog
FROM Project_12345..Demography_Current
-- To refresh the age column later:UPDATE Project_12345_Working..Demog
SET Recalculated_Age = DATEDIFF(year, anon_date_of_birth, GETDATE())
with engine.connect() as conn:
df = pd.read_sql("SELECT * FROM Project_12345..Demography_Current", conn)
# anon_date_of_birth is already a datetime column
df["Recalculated_Age"] = (
pd.Timestamp.now().year - df["anon_date_of_birth"].dt.year
)
df.head()