Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - There are two time parameters in the sql server custom function. How to judge whether two times are the same? Ask the master to help you solve it. Thank you.
There are two time parameters in the sql server custom function. How to judge whether two times are the same? Ask the master to help you solve it. Thank you.
declare @ dt 1 datetime = ' 20 13- 1-2 '

declare @ dt2 datetime = ' 20 13-5- 1 '

declare @ dt 1 datetime = ' 20 13- 1-2 '

declare @ dt2 datetime = ' 20 13-5- 1 '

if(year(@dt 1)=year(@dt2))

Print "same year"

if(month(@ dt 1)= month(@ dt2))

Print "same month"

if(day(@dt 1)=day(@dt2))

Print' same day' uses the year()month() day () method to get the values of parameter variables for comparison.