SQL/ASP.NET getting DATE to work in query

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default SQL/ASP.NET getting DATE to work in query

    I'm grabbing today's date with some ASP.net code:

    Dim Today As Date
    Today = Microsoft.VisualBasic.Today()

    I'm then trying to run a SQL query with the following WHERE statement:

    WHERE postdate <= " & Today & "

    But it's pulling up records that have a postdate in the future.

    A sample:

    Today (when written to screen) = 3/23/2005 12:00:00 AM
    In the SQL table postdate field = 3/28/2005

    Anyone see something wrong with what I have that would be causing this? Is
    it because in my code I'm grabbing the time, while SQL is only storing the
    date?

    -Darrel


    darrel Guest

  2. Similar Questions and Discussions

    1. Query by date doesn't work
      I'm using Informix 9.3, If I run the query in Informix it works, when I run the same query in ColdFusion I get a string to date conversion. I'm...
    2. date query problem, date in variable
      I am using the following query : $query_archief = "SELECT * FROM vacatures where dd_eind_plaatsing < $dd_eind_plaatsing_archief1" note:...
    3. PHP Date Query
      I'm trying to create a recordset where I query a date field in my database. I can't figure the syntax. A little help here: WHERE Category =...
    4. Date Query
      I am attempting to pull information from a database and the main criteria of how I retrieve the information in a date format. The startdate and...
    5. Date query in ASP
      ASP/Scripting newbie question here. I have an access database that I am writing ASP pages to query and return the results. The end user can put...
  3. #2

    Default Re: SQL/ASP.NET getting DATE to work in query

    Use the datediff() function. eg

    where datediff('d',myfield,date())<=0

    --
    Jules
    [url]http://www.charon.co.uk/charoncart[/url]
    Charon Cart 3
    Shopping Cart Extension for Dreamweaver MX/MX 2004


    Julian Roberts Guest

  4. #3

    Default Re: SQL/ASP.NET getting DATE to work in query

    > Use the datediff() function. eg
    >
    > where datediff('d',myfield,date())<=0
    So, that's the difference between my date in the database and todays date in
    days? How is the day measured? Ie, is that the number of days since 1900 (or
    whatever the default date is in SQL?

    -Darrel


    darrel Guest

  5. #4

    Default Re: SQL/ASP.NET getting DATE to work in query

    > Use the datediff() function. eg
    >
    > where datediff('d',myfield,date())<=0
    Hmm...well, I tried this:

    datediff('d',pulldate,date()) <= 0

    and got this:

    'date' is not a recognized function name.

    -Darrel


    darrel Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139