In your example, you are comparing a string ("2023-01-01") with the values stored in the "variable.name". Strings can not be compared but date objects can be. Probably you can do the following....
df$variable.name = as.Date(df$variable.name) #make sure the variable is date object
df2023 = subset(df,df$variable.name >= as.Date("2023-01-01") & df$variable.name <= as.Date("2023-12-31"))