Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6133957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:17:45+00:00 2026-05-23T17:17:45+00:00

I have designed a basic search in ASP/C# for searching through records in a

  • 0

I have designed a basic search in ASP/C# for searching through records in a database and have provided the user with these fields which they can use to search: word/phrase, dateFrom, dateTill. So entering “Hello, World!”, 05/25/2009, 06/25/2009 respectively will search for a database record with the contents “Hello, World!” which was created between the given dates. Pretty simple stuff.

The text entered by the user into the fields is injected directly into an SQL statement like follows:

SELECT r.idRecord, r.recordText
FROM record r
WHERE LOWER(CAST(r.recordText AS VARCHAR)) LIKE LOWER('%" + word/phrase + "%')
  AND r.creationDate BETWEEN '" + dateFrom + "' AND '" + dateTill + "'"

So still pretty simple and it works like a charm when the user enters dates in an American format, mm/dd/yyyy. However, it fails when a date in British format is entered like, 25/05/2009. Finally…

SELECT CONVERT(VARCHAR(10), GETDATE(), 103) AS [DD/MM/YYYY]

…doesn’t particularly help because I don’t want to select the date, can a similar statement be used in the WHERE clause?

Thanks for the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:17:45+00:00Added an answer on May 23, 2026 at 5:17 pm

    Parse the value entered by the user into a DateTime data type using the DateTime.ParseExact method. This method allows you to specify the format of the datetime, so you can use dd/MM/yyyy or MM/dd/yyyy, depending on your user’s preferences. Then pass the DateTime value as a parameter to your SQL statement.

    Here is a blog post that explains

    • how to use parameterized SQL statements and
    • why SQL-by-string-concatenation is evil:

    Coding Horror: Give me parameterized SQL, or give me death

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have designed database tables (normalised, on an MS SQL server) and created a
I have designed this gui in netBeans which has a canvas , a couple
I am planning to build a database for a school application. I have designed
I have designed a quick and basic vector arithmetic library in C++. I call
This might be a basic CSS question: I have a site designed with well-defined
I have a certain POJO which needs to be persisted on a database, current
I have Designed the Javascript function My.js it contains following code My.js function display(){
I have designed a tabbed page. I'm able to load forms in the tabs
I have designed a custom section handler before but I'm faced with a problem
I have designed a new web site. I have hosted it online. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.