---
title: "How to list all dates between two dates"  
description: "How to list all dates between two dates"  
author: "Kate Smith"  
published: 2013-07-08  
updated: 2013-07-08  
canonical: https://www.mindstick.com/forum/1265/how-to-list-all-dates-between-two-dates  
category: "mssql server"  
tags: ["mssql server"]  
reading_time: 1 minute  

---

# How to list all dates between two dates

Hi [Expert](https://www.mindstick.com/articles/13120/an-expert-financial-advice-will-improve-your-finances)! \
I would like list dates between two [date](https://yourviews.mindstick.com/story/3869/propose-day-2024-exciting-date-ideas-for-you-and-your-partner) in a [SQL Server](https://www.mindstick.com/articles/12999/what-is-table-valued-function-in-sql-server) [stored procedure](https://www.mindstick.com/articles/803/using-stored-procedure-in-asp-dot-net).\
For example:\
Date1: 2015-05-28Date2: 2015-05-31\
[Results](https://yourviews.mindstick.com/story/4497/usage-of-baking-soda-magical-results) :\
2015-05-292015-05-30\
How to calculate all dates between [two given dates](https://www.mindstick.com/interview/33843/how-to-find-the-difference-between-two-given-dates-in-sql-server)?\
Thanks in advance.

## Replies

### Reply by AVADHESH PATEL

Hi Kate!\
Create a [stored](https://www.mindstick.com/forum/157561/what-is-the-stored-procedure-create-a-procedure-to-find-the-record-by-stu_id-from-the-student-table) procedure that does something like the following:\
**declare @startDate date;****declare @endDate date;****\****select @startDate = '20150528';****select @endDate = '20150531';****\****with dateRange as****(** **select dt = dateadd(dd, 1, @startDate)** **where dateadd(dd, 1, @startDate) < @endDate** **union all** **select dateadd(dd, 1, dt)** **from dateRange** **where dateadd(dd, 1, dt) < @endDate****)****select *****from dateRange****\**I hope it helpful for you.\


---

Original Source: https://www.mindstick.com/forum/1265/how-to-list-all-dates-between-two-dates

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
