How to compare Calendar Control Dates to MS Access Dates?

I am trying to use TodaysDate from calendar control of ASP.Net to query a MS Access DB & retrieve records that satisfy the condition of today's date falling within a specified range.

My ASP.NET script reads:
sql="SELECT * FROM calendar WHERE ( " + Calendar1.TodaysDate + " BETWEEN date_start AND date_end)"

date_start and date_end are both using the TIME/DATE (General Format) in MS Access.
I tried to run the query but it return an empty result even though today's date falls within the range of date_start and date_end, eg:
Calendar1.TodaysDate is 5/6/2004 &
a record has date_start as 5/4/2004 & date_end as 5/7/2004
I tried to get both of them to be the same format MM/DD/YYYY MM:HH:SS AM but still couldnt get it to work. Any idea how to get it working right?
5/6/2004 8:58:17 AM 91979 articles. 4 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 2

Use Parameter objects instead of string concatenation. It will make your life so easier, and you'll be safe from Sql Injection Attacks.
This posting is provided "AS IS" with no warranties, and confers no rights.
5/7/2004 12:01:50 AM
What's the difference between them ?

Could you said it in details, I am a new.
Thanks for your help!
5/7/2004 1:24:04 AM
For more info, check this article.  It explains WHY you should use the SqlParameter/OleDbParameter classes instead of string concatenation...
Tim *IceMan* Musschoot

Software Engineer

AspNL Moderation Team
5/7/2004 9:29:00 AM

Similar Artilces:

Comparing date from Calendar control with date in Acces db
Hi, I'm making a project for school and we have to set up a site for online ticketing service for TGV. All really simpel and not to extensive. I have the following problem: To select a journy a user have to point out his starting point and his point of arrival. Also they have to give the date of departure. I created two dropdownboxes for the startpoint and the point of arrival. For the date I implemented an Calendar Control. With the following Sql-statement I want to select the right journy for the user: strSql = "SELECT tblStartplaatsen.STARTPLAATS_stad, tblTussenstoppen.T...

calendar date span (date start : date end)
Hi! Can anyone help me with this? Say, I have these two textboxes. Date Start:        Date End:             What I wanted to do is to put dates on it using the calendar. My problem is I do not know what to do to keep the "Date Start" not way after the set "Date End", and for "Date End" not way before the set "Date Start".   example: Date Start: July 1, 2008              &nb...

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

User selects date from Calendar control, but textbox won't get populate chosen date...
  Hi again, I'm following this tutorial: Basically, I'm working with a Calendar control.  I have a textbox and right beside it, a little calendar image.  User clicks on calendar, clicks on a date, the date should automatically (code does the work), populate the textbox with the selected date.  Welp, mine's not doing that :(  The article contains VB, so maybe I'm missing something.  I'd like to k now what the hidden textbox control does, and how exactly are we passing the date into...

getting today's date to appear on the .net web calendar control
try as I have i cannot get the today's date displayed at the bottom of my web calendar control.  is there any special option i should set on my calendar control properties ? Hi, what did you mean by at the bottom of my web calendar control ? Is is highlighting the day number of current date? Try this,Calendar1.SelectedDay = DateTime.NowCorrect me if I misunderstood your question. :)Alvin ChooiMicrosoft ASP.NET™ Enthusiast v1.1 / v2.0, Malaysia Blog : hi,   I can see the selected date eg if if do what you say:    Calendar1.Se...

Daterange Picker Calendar control Without clicking Start Date and End Date Separately ( dd/mm/yyyy-dd/mm/yyyy format
Hello all,  Plz Suggest me the Daterange Picker Calendar control . so that i can select a range of date (after clicking on button javascipt calendar will be executed) and date will appear in the format dd/mm/yyyy-dd/mm/yyyy in listbox (like without cliking for Start Date and End Date Separately)  Swati Jain   Check this: NC... Some of the third party Calendar controls allow multiple selections. If they support the ability to just click on the start and then end dates to form a range, or can limit the u...

Retrieve Only Date from Date/Time in Ms Access
Hello,When retrieving data from an ACCESS database table, I want the generated ASP page to display only the date inputted by the user. It currently displays the date and then the time is always 12:00. Anyone have any suggestions as how I can have it display only the time, but leave the access format as Date/Time? Format the output - use {0:d} Something like:label1.text=String.Format("{0:d}",YourDate)David WierMCP/ - where to look first!Please Vote for ASPNet101 - 'Best Community Resource'!Control Grouper - easily control properties for multipl...

compare date to a date
I have in a where clause the following statement. SELECT "sales"."sale_date", "sales"."ling_no", "sales"."course_no", "sales"."product_no", "sales"."service_no", "sales"."quantity", "sales"."amount", "payment"."amount", "payment"."payment_form" FROM "payment", "sales" WHERE ( "sales".&...

How make current date the selected date in Calendar control?
I have a calendar control that provides a date for a report. I'd like the current date to be the seleected date by default. Currently my code works fine when the user seleects a date. However, even though the current date is shown in the calendar, if the user does not specificaly click on it, it is not in the 'selected date'. Hope this is clear. Assign Selected data in the page load. That should solve the issue. gazolba:I'd like the current date to be the seleected date by default.Do something like this belowprotected void Calendar1_Load(object sender, EventArgs e){&nb...

How to convert Julian date into Calendar date (VB.Net)
Hi all, I have some dates which are in Julian format and I need to convert them into calendar dates  for example if the Julian date is 1, I need to be able to convert it into 1/1/2007, If the julian date is 66 then I would need to convert it to 3/7/2007 and so on. Every year would start with 1 and end with 365365 = 12/31/2007. Is there a function or tutorial somewhere ? thanks for any help.    1) Your dates aren't in Julian format!! 2) How do you know which year you are referring to? 3) Have you tried the AddDays function of the Date/DateTim...

Calendar start date 3 days after current date
Hi, I have a textbox that populates with the current date.  I also have another textbox with a calendar extender and I would like the calendar to start 3 days after current date and also disable the previous arrow (the user cannot select a date that is prior to 3 days from current date. I am using 2.0 with vb.  thanks in advance, bardel ...

Get Date and compare with Date.Now in T-SQL
I am trying to set an alert to user for a project which will due on the particular date. How to compare the DateTime due date  which I get from the database with the Date.Now in stored procedure? Thanks in advance.Best regards,Ron. Make sure they are both in the same format. Many different ways to accomplish. The example below would convert both to a date: select * from table where convert(nvarchar(15),DueDate,101) = convert(nvarchar(15),Date.Now(),101) Thanks samsta, but I got an error when I am using Date.Now(). Then, I change with GetDate() function and works just ...

Calendar control get date problems
Hi, in calendar control , how can i get the date format with double integer at day, like 10/03/2005, because i got the format with 10/3/2005i just use "text1.Text = Calendar1.SelectedDate" any idea? Try formatting it:      text1.Text = Calendar1.SelectedDate.ToString("MM/dd/yyyy")NC......

Calendar Control: First date displayed and last date displayed.
I am trying to get the first date displayed and the last date displayed from the calendar control so I can run a database query to pull back all events in that date range.  May for example will show April 29th to June 9th.  Anybody know how to get these dates from the control? Look at this post from a couple of days ago - I believe it addresses your problem. Sam  That example uses the SelectedDate from two calendar controls, one for the start date and one for the end date.  What I want to is get the first ...

Web resources about - How to compare Calendar Control Dates to MS Access Dates? -

The beard calendar
How am I not in this? ∞ Read this on The Loop

Thai solar calendar - Wikipedia, the free encyclopedia
The Thai solar calendar , Suriyakhati ( Thai : สุริยคติ ) was adopted by King Chulalongkorn (Rama V) in AD 1888 as the Siamese version of the ...

'Beards of Ipswich' calendar models
A few of the beard models who featured in Jason McNamara's 'Beards of Ipswich' calendar.

Google launches Reminders to bring to-dos into Calendar mobile apps
Today Google Calendar for both Android and iOS gains a handy new Reminders feature that works alongside the app’s to-dos feature. With the Reminders ...

‘Ski or Squeal’ in Angry Birds Seasons’ new Advent calendar episode
Tis the season once again for the rollout of the Advent calendar episode of Angry Birds Seasons . In holiday seasons past, the seasonal edition ...

At last! Google Calendar gains to-do lists with Reminders
When it comes to keeping on top of appointments, Google Calendar is certainly a useful tool but it's a long way from perfect. It's very capable ...

Add to-dos to your Google Calendar using Reminders
Posted by Vijay Umapathy, Product Manager Our calendars should help us make the most of our time — scheduling meetings at work, remembering ...

Reminders in Google Calendar
Google Calendar's apps for Android and iOS now let you add reminders, just like you can do using Google Keep, Google Search or Google Inbox. ...

List: More Mass Shootings Occurred In U.S. In 2015 Than There Are Calendar Days In The Year
More mass shootings have occurred in the United States throughout 2015 than there are calendar days in the year itself, according to a list by ...

Google adds to-do lists to Calendar
The updates lets you set reminders in your calendar

Resources last updated: 12/9/2015 1:30:41 AM