1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Sorting database fields by 'datetime' date

Discussion in 'C#' started by VAIO, Oct 9, 2006.

  1. #1
    Hi. I have never used ASP before, but I have been given the task of creating a ASP Web interface to display the results of a database query. I need to have a form that allows the user to sort the results by date range. The database has the date and time stored in a 'datetime' data type field called "eventtime".

    The first thing i need to do is create a variable, lets say "eventdate", that takes just the date out of the datetime field so i can compare it to the user input dates. However, i assume i need to somehow do this after i make the 'rs' connection to the database, but before i construct and execute the query.

    I then need to have the form i create post the user date values into variables that i can also use in the query. Let's say "startdate" and "enddate". Should i use POST or GET to retrieve the the user input?

    I then need to construct a query with all variables in it that searches for the correct date range. Something like:

    "select * from table where" & eventdate & ">" & startdate & " and " & eventdate & "<" & enddate & ";"
    Code (markup):
    I'm sure my syntax might be a little off, but please correct it as you see fit.

    Also, a simple bounds checking procedure would be nice to make sure the user actually entered a date.

    Any help with any and all of this would be greatly appreciated.
     
    VAIO, Oct 9, 2006 IP
  2. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #2
    add the following at the end of your query string
    or
    so its gonna be

     
    ludwig, Oct 10, 2006 IP