Get the dates between two dates

Hi all,

I want to get all the date between two dates. For example I have a StartDate="12/5/2003" and a EndDate="12/7/2003"
the result should be

Ant help is appreciated
12/29/2003 8:15:37 PM 91979 articles. 2 followers. Follow

6 Replies

Similar Articles

[PageSpeed] 4

for ( DateTime theDate=StartDate ; theDate<=EndDate ; theDate.AddDays(1) )
// Do something...theDate.ToShortDate() would give the string...

Starting with ASP.NET 2.0? Look at:
Programming Microsoft Web Forms
My Blog
12/29/2003 8:42:17 PM
I get a syntax error as :"For loop variable cannot be of type Date"
12/29/2003 8:49:20 PM
Hmm.  The below works for me (there was a problem in the previous code).

private void button1_Click(object sender, System.EventArgs e)
string Dates=string.Empty;
DateTime StartDate=DateTime.Parse("2003-12-05");
DateTime EndDate=DateTime.Parse("2003-12-07");
for ( DateTime theDate=StartDate ; theDate<=EndDate ; theDate=theDate.AddDays(1) )
// Do something...theDate.ToShortDate() would give the string...

Starting with ASP.NET 2.0? Look at:
Programming Microsoft Web Forms
My Blog
12/29/2003 9:02:23 PM
I am still getting the same error. It might be because Option Strict On and Option Explicit On 

12/29/2003 9:21:17 PM

select lastvisit from yaf_user
where Convert(varchar(25),lastvisit,120) >= Convert(varchar(25),dateadd(dd,-30,getdate()),120)
and Convert(varchar(25),lastvisit,120) <= Convert(varchar(25),getdate(),120)


try this query .....  

yaf_user my table name 

lastvisit fieldname of my table 

120  formate of date

-30 it's a display record which is last 30 days ago from current date..

u cn take +30 for next 30 days record regrading ur problem u can take +[2 months] or +90[approx] it's 


more info abt format go to link

2/16/2008 1:22:14 PM

try this, i think this more simple :

DateTime startDate = DateTime.Parse("12/5/2003");

DateTime endDate = DateTime.Parse("12/7/2003");

while (startDate.CompareTo(endDate) <= 0)


Label1.Text += startDate.ToShortDateString() +
" - ";

startDate = startDate.AddDays(1);


2/16/2008 1:37:36 PM

Similar Artilces:

get a date from two date field
how to use a stored procedure to get a date which is start_date + due_date. stare_date and due_date are data field. dats type are smalldatetime. database is SQL 2000.   Give an example of what you want..... Do you want something like 12/12/2005 12/25/2005 ? Eric RamseurRainbow Portal 2.0 AdminDownload Rainbow 2.0!!Rainbow Code Rainbow Portal CommunityC# 2005 Group I need a date, 60 days before start date +  due days. For example, start is 12/03/2005(smalldatetime) Due days is 20(int).   start date + due day - 60 is 10/23/2005. that's what I...

How to get all Dates b/w two dates
Hi, How can i display all the dates b/w two dates in or -------------------------------------------------------------------------  Example: Date_1: 12/01/2009        Dates_2: 14/01/2009 Results: 12/01/2009 13/01/2009 14/01/2009 -----------------------------------------------------------------   Do you just want to get the dates, or are these dates stored in a database somewhere?David WierMCP/ - where to look first!Please Vote for ASPNet101 - 'Best Community Resource'!Control Grouper -...

Getting dates between 2 dates
Hi all, Would like to make an enquiry, if i have 2 dates, how can can i get all the dates between these 2 dates. Thanks for the help.   You will probably need to loop through the dates;               DateTime startdate;            DateTime enddate;            List<DateTime> allDates = new List<DateTime>();            allDates.Add(startdate);         ...

Dates, Dates, Dates!
Hello all... I am in the process of building an appointment system, and I am trying to see if I can get some pointers on which way to go on this. The first version of this appointment system was very lo-tech, and it stored all of the possible dates/times in the database. Once a user booked an appointment, their information was logged to that date/time, and then that date/time would no longer show in the list of possible openings. This was great for a temporary fix, but with having to pre-populate all of the dates/times, the system would eventually have to be updated to continue on pa...

getting date in between 2 date
how do i get the date in if it is within the 2 date? er... don't know how to phrase i think my sql is something like this: SELECT * From Transaction WHERE Date BETWEEN 01/08/1900 AND 31/08/2000 BTW i declare my Date as date/time(short date) is it possible with the sql? it display Syntax error in FROM clause. SELECT * From [Transaction] WHERE [Date] BETWEEN #01/08/1900# AND #31/08/2000# Now, this presumes that the machine in question is expecting dates in dd/mm/yyyy format. Note that Transaction and Date are likely reserved words, and so I have enclosed them in [ and ...

How to get week start date, End date for a given week nunber,year?
I want  a javascript function to to get the starting date and end date of a week when I have given the week number (1 to 5), Month number (1 to 12), valid year as parameter. How to do that?Manivannan  You can visited dont have example.Hope it's help you. try this example function GetWeekStartEndDate(){    var week = 5;    var month = 4;    var year = 2008;        var PositiveOneDay = new Date(new Date('1/2/2000') - new Date('1/1/2000'));   &...

get only date from a date with a datetime format
i have a problem with dates when it comes to searchingbasically, SQL searches for a date including the seconds,but i only need to date so that in any given time, it will yield a's a part of my code-behind code: reqNo = RequisitionsLogic.GetReqNoByDate(currentDate, requestorCode)and here's the SQL statement created in a TableAdapter:SELECT RequisitionNoFROM RequisitionsWHERE (RequisitionDate = @RequisitionDate) AND (RequestorCode = @RequestorCode) take a look with this, don't just accept influenceshttp://thedailyarr.tk

getting dates beyond the date range
I am having problems with my codes. I do not know how to do it. What I wanted to do is some what like this:Say I have a vacation table for a person. this vacation has a limit of only 5 days, let's say. What if that person's vacation already exceeded to 5 days. 6 days probably. How would I put this in codes?  example:table:Vacation1/14/084/25/085/1/085/5/086/4/088/19/08The person has only 5 allowable vacations. But table:Vacation exceeded one day. How can I show, in a gridview, the exceeded date, 8/19/08? I am using Visual Web Developer ASP.NET C# language with SQL Server 2005 fo...

getting the current date ONLY from the current date
Hello all.  I've searched for the better part of a couple of hours to try and capture just the current date WITHOUT  the time to make a comparison with.  right now I have a variable as a date equal to now(), i've tried to cast it for just the date in a variety of ways, but it always grabs the current time too, so in my sql statement it will never have a match.  I've tried tostring(), i've tried date() i've tried now(date), i've tried many things that I know makes absolutely no sense just to get the date without the time.  I know it's not t...

Get first date and last date from a range
I have a sql database with values that include a date and a true-false bit (chkbx).My sqldatasource looks like this:        <asp:SqlDataSource ID="RangeDatesSqlDataSource" runat="server"             ConnectionString="<%$ ConnectionStrings:BPTracking %>"             SelectCommand="SELECT [Date], [chkbx] FROM [BPTable] WHERE ([chkbx] = @chkbx)">         &n...

when max(date) is not working: getting the most recent date
Hi Guys,I have the following simple query: SELECT     MAX(T_SHIPMENT.ROUTERECORDTIME) AS MAXDATE, T_JOB.VEHICLEIDFROM         T_JOB, T_SHIPMENTWHERE     T_JOB.SHIPMENTID = T_SHIPMENT.SHIPPKIDGROUP BY T_JOB.VEHICLEIDHAVING      (MAX(T_SHIPMENT.ROUTERECORDTIME) IS NOT NULL)Which is working fine, I get two results - both are the most recent dates for the vehicles.When I now add LONGITUDE  the query looks like this: SELECT     MAX(T_SHIPMENT.ROUTERECORDTIME) AS MAX...

How to get the dates of certain days in a date range?
I want to build a schedule for tv series given a start & end date and the day of show and the day of the rerun, for example if series shows on wednesdays & the rerun is on thursdays and the series will start showing from 07/02/07 till 14/03/07. I want to get all the dates of wednesdays & thursdays in this date range & insert records in a table like thisSeriesId   DateOfShow1             07/02/071             08/02/07  1             14/02/071           &...

getting a date picker widget for a date field
The tutes say to bind the field to an xsd:date to get a date picker. I do that. The example works fine for static pages. Great. However when I try to incorporate this into my form, where the instance is loaded dynamically like this: <xf:submission action="retrieve.php" method="post" replace="instance" instance="mydata" id="retrieve" /> I get the form and data filled out fine, but no date picker for date fields. Ok so maybe I need to bind after the submit is done, so I add this: <xf:send submission="re...

How to get the Create Date and Modified Date of a file
Does anybody know how to get the Create Date and Modified Date of a file, having the path and filename. Any help is greatly appreciated. I don't know the answer, but a guy named Vikas probably does. Hopefully he will read your post and give you a better clue. I am also interested in the answer to this question. Here is a post he wrote a while ago about how to find a particular file: Hi, Is the name of the file is fixed? and the path of the file may vary from time-to time? If yes, then you can use windows API function FindFirstFile() to search for the path of your file. The...

Web resources about - Get the dates between two dates -

An Apology to Bernie Sanders
Hardly a week goes by without some demand for an apology populating my inbox. I have never apologized for two reasons: The usual one is that ...

Kim Kardashian's new app crashed Apple's App Store
Kim Kardashian's new app, which is a collection of emoji that resemble her, crashed Apple's App Store after it was released yesterday, according ...

SpaceX publishes more pics and video of Falcon 9 rocket landing
SpaceX finally had its fairly tale ending and successfully landed its Falcon 9 rocket first stage back on the ground safely after launch. This ...

Graham's Exit Opens Doors in New Hampshire, South Carolina
Lindsey Graham may not have resonated in the polls, but his exit from the Republican presidential race will open doors to other candidates in ...

British troops deploy to Afghan province amid Taliban battle
KABUL, Afghanistan (AP) — Fierce battles were underway Tuesday between Afghan forces and the Taliban in southern Helmand province where the insurgents ...

Bergdahl Set to Face Charges
Army Sergeant Bowe Bergdahl is set to be arraigned this morning after he allegedly deserted his unit and was then held captive by the Taliban ...

Apple Confirms “Leaked” MacBook Is Not A New Device
Image credit – CBS/TechInsider Apple was recently profiled on Charlie Rose’s 60 Minutes segment and while the profile was interesting, like ...

FDA lifts Ban on Blood Donation by Gays
I4U News FDA lifts Ban on Blood Donation by Gays I4U News The FDA revised its policies with reference to blood donors. The major risk was ...

Will Norman get fined? Clearing up 5 Odell Beckham questions
Giants receiver Odell Beckham Jr. has been suspended one game by the NFL for what the league stated was “multiple violations of safety-related ...

Judge: Officers in Racists Texts Case Can Keep Their Jobs
Judge rules San Francisco police officers in racists texts case can keep their jobs

Resources last updated: 12/22/2015 11:56:22 AM