Count days in date range but only for a specific year within the date range
Assuming your table has a StartDate and EndDate field, you can use a CASE statement to calculate the days difference between the end date and either 01/01/2019 or the start date of the range.
SELECT ID, StartDate, EndDate, 
  (CASE
    WHEN StartDate &lt; '2019-01-01' THEN DATEDIFF(DAY, '2019-01-01', EndDate)
    ELSE DATEDIFF(DAY, StartDate, EndDate)
  END)+1 AS DaysInRange
FROM Dates

db&lt;&gt;fiddle