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.

 

0
leolander
9/19/2007 9:10:56 AM
asp.net.getting-started 91979 articles. 4 followers. Follow

2 Replies
906 Views

Similar Articles

[PageSpeed] 50

You will probably need to loop through the dates;  

 
            DateTime startdate;
            DateTime enddate;

            List<DateTime> allDates = new List<DateTime>();
            allDates.Add(startdate);

            while(startdate < enddate)
            {
                startdate = startdate.AddDays(1);
                allDates.Add(startdate);
            }

            allDates.Add(enddate);
0
stuohy
9/19/2007 10:28:21 AM

 you can use the following query,,,

select * from tablename where date between startdate and endate 

 


Vasanthakumar
Software Engineer.
0
vasanth
9/19/2007 10:32:52 AM
Reply:

Similar Artilces:

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 ...

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...

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 12/5/2003 12/6/2003 12/7/2003 Ant help is appreciated Thanks 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 I get a syntax error as :"For loop variable cannot be of type Date" Hmm. The below work...

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 http://www.datejs.com/2007/11/I 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'));   &...

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...

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...

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 result.here'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.tkhttp://www.ftpx.com/index...

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...

How can I have 2 dates and select all records that have a date field with a value between those 2 dates?
I have 2 textboxes, 1 for the start date and 1 for the end date and I want the user to be able to enter 2 dates and select records from SQL that fall between those 2 dates. I have the code working in classic asp but am getting an error with .net. This is the code i have: Dim enddate As Date Dim startdate As Date enddate = Request.form("date_from") startdate = Request.form("date_to") strSelect = "SELECT id, title, category, dateadded FROM news WHERE category = 'articles' AND dateadded BETWEEN '" & startdate & "' AND '" &...

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...

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           &...

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...

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...

Web resources about - Getting dates between 2 dates - asp.net.getting-started

Here's What Vladimir Putin Really Said About Donald Trump Today
LA Times reporter Michael Hiltzik has spent time reporting from Russia and speaks the language well. Via email, he offers this explanation of ...

Zeitgeist 2015, A Curated List of the Year’s Favorite Music Tailored to Different Moments of the Day
Keep Being You – Isyana Sarasvati (“Start the Day”) Brooklyn-based music blog Hype Machine has again put together Zeitgeist 2015 , their wonderful ...

Notable Mistrials in Cases of Police Deaths
Hung juries not uncommon in high-profile cases involving use of force by police

The Feds Didn't Seize Shkreli's Wu-Tang Album This Morning, an FBI Spokesperson Says
When Martin Shkreli was arrested by federal agents for fraud this morning , the first thought in your head was probably something along the lines ...

U.S. House approves permanent tax breaks in massive bill
It makes permanent dozens of costly corporate tax breaks such as the research and development tax credit that had until now have been temporary. ...

California DMV draws up some pretty harsh self-driving-car regulations
As autonomous cars graduate from testing to actual deployment, the Department of Motor Vehicles is drawing up regulations that err heavily on ...

The bizarre suspension of WhatsApp in Brazil
The Facebook-owned messaging service has been suspended today for several hours due to a court order, affecting nearly 100 million users. Despite ...

New Windows 10 phones now come with Office Mobile preinstalled
Microsoft today announced that it will now ship Windows 10 phones, such as the Lumia 950, with Office Mobile apps preinstalled. The announcement ...

Colorado Marijuana Lawsuit: Obama Administration Asks Supreme Court To Reject Suit Filed By Neighboring ...
The Obama Administration has asked the Supreme Court not to hear a lawsuit against Colorado by neighboring states over Colorado’s legalized marijuana, ...

Pentagon chief admits 'mistake' in using personal email
US Defense Secretary Ashton Carter acknowledged Thursday making a "mistake" when he used his personal email for government business in the early ...

Resources last updated: 12/17/2015 8:57:12 PM