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.

Querying dates with SQL and MSAccess

Discussion in 'C#' started by camjohnson95, Mar 6, 2011.

  1. #1
    I just recently wasted a lot of time solving what was a fairly simple issue regarding the querying of date ranges with ASP.NET and MSAccess. Hopefully this post will prevent anyone else with problems in the future.

    When querying a date range with SQL and MSAccess the format of the date must be:
    "MM/dd/yy HH:mm:ss".
    Even though a date object can be stored in another format, when querying with SQL it MUST be in this format. Take not that the capital "HH" means it is in 24-hour time format. If you use regular time format it will come across issues.

    The easiest way to format a date correctly in asp.net is:
    myDate.ToString("MM/dd/yy HH:mm:ss")

    MM/dd/yyyy will probably also work.
     
    camjohnson95, Mar 6, 2011 IP