Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in SQL by (20.3k points)

I have two tables where column [date] is the type of DATETIME2(0).

I have to compare two records only by their Date parts (day+month+year), discarding Time parts (hours+minutes+seconds).

How can I do that?

1 Answer

0 votes
by (40.7k points)

To compare the date part, you can use the CAST to the new DATE data type in SQL Server 2008 

IF CAST(DateField1 AS DATE) = CAST(DateField2 AS DATE)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...