Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 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.4k 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)

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...