Home > Enterprise >  T-SQL MIN on Date type resulting in INT
T-SQL MIN on Date type resulting in INT

Time:07-23

I have a table with a column called ThisDayOfTherapy which is of datatype DATE in SQL Server. Later, I have an aggregate query using Min(ThisDayOftherapy). This query populates a #temp table with the result of Min(ThisDayOfTherapy) as column name StartDate_Min

In a 3rd location I am finally doing something with StartDate_Min. When I hold my mouse over StartDate_Min, it says the datatype is INT.

Shouldn't it simply be DATE? Will it still work as if it were a date for all practical purposes?

CodePudding user response:

I see the same behavior, but I think you will be fine. SQL Server would not execute any date functions if it was not a valid date. Adding one day to my MinDate column from my temp table is working as expected.

enter image description here

  • Related