---
title: "How to search record by date in SQL Server?"  
description: "How to search record by date in SQL Server?"  
author: "Revati S Misra"  
published: 2023-04-05  
updated: 2023-06-21  
canonical: https://www.mindstick.com/interview/33861/how-to-search-record-by-date-in-sql-server  
category: "mssql server"  
tags: ["sql server", "sql"]  
reading_time: 3 minutes  

---

# How to search record by date in SQL Server?

You can select the record date-wise after converting the date column datatype of the table into another datatype.

## Syntax:

SELECT * FROM Table_Name WHERE CONVERT(DataType, Column_Name, format) = ‘DD-MM-YYYY’;

## Example:

SELECT * FROM Customers WHERE CONVERT(VARCHAR, Join_Date, 105) = ‘01-01-2020’

## Answers

### Answer by Aryan Kumar

To search record by date in SQL Server, you can use the WHERE clause to filter the results by the date column. For example, the following query will return all records from the products table where the date_created column is greater than or equal to 2023-01-01:

SQL

```plaintext
SELECT *
FROM products
WHERE date_created >= '2023-01-01';
```

You can also use the BETWEEN operator to search for records between two dates. For example, the following query will return all records from the products table where the date_created column is between 2023-01-01 and 2023-01-31:

SQL

```plaintext
SELECT *
FROM products
WHERE date_created BETWEEN '2023-01-01' AND '2023-01-31';
```

Here are some other ways to search record by date in SQL Server:

- Use the LIKE operator to search for records that match a certain pattern. For example, the following query will return all records from the products table where the date_created column contains the string "2023":

SQL

```plaintext
SELECT *
FROM products
WHERE date_created LIKE '%2023%';
```

- Use the IN operator to search for records that are in a list of dates. For example, the following query will return all records from the products table where the date_created column is in the list of dates ['2023-01-01', '2023-01-02', '2023-01-03'].

SQL

```plaintext
SELECT *
FROM products
WHERE date_created IN ('2023-01-01', '2023-01-02', '2023-01-03');
```

### Answer by Rocky Dada

To search records by date in SQL Server, you can use the **WHERE** clause in a **SELECT** statement along with the appropriate comparison operator to compare the date values in your table with a specific date or date range. Here are a few examples:

## Search for records on a specific date:

`SELECT * FROM your_table WHERE date_column = '2023-04-10';`

Replace **your_table** with the name of your table and **date_column** with the name of the column that contains your date values. This query will return all records where the date value in **date_column** is equal to the specified date (in this case, '2023-04-10').

## Search for records within a date range:

`SELECT * FROM your_table WHERE date_column BETWEEN '2023-04-01' AND '2023-04-10';`

This query will return all records where the date value in **date_column** falls within the specified date range (in this case, from '2023-04-01' to '2023-04-10').

Note that in both examples, the date values are enclosed in single quotes. This is because date values in SQL Server are treated as strings and need to be enclosed in quotes for the query to work correctly.

| ID | Name | Date |
| --- | --- | --- |
| 1 | John Doe | 2023-04-01 |
| 2 | Jane Doe | 2023-04-02 |
| 3 | Bob Smith | 2023-04-02 |
| 4 | Alice Lee | 2023-04-03 |

\

### Answer by Revati S Misra

You can select the record date-wise after converting the date column datatype of the table into another datatype.

## Syntax:

SELECT * FROM Table_Name WHERE CONVERT(DataType, Column_Name, format) = ‘DD-MM-YYYY’;

## Example:

SELECT * FROM Customers WHERE CONVERT(VARCHAR, Join_Date, 105) = ‘01-01-2020’


---

Original Source: https://www.mindstick.com/interview/33861/how-to-search-record-by-date-in-sql-server

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
