Access SQL- Date comparison problem

Ask a Question related to ASP, Design and Development.

  1. #1

    Default Access SQL- Date comparison problem

    I use an Access-database where one column stores a date originating from
    this code:

    Indate = FormatDateTime(date(),vbgeneraldate)

    I then want to be able to show postings from the database being i.e.
    smaller than current date.
    So I use the current date from a code same as the above code and want to
    compare with dates in the database.
    The column in the database is in Date/time format and a posting from
    today will read 2004-01-31

    In my process page code I do this

    Dim Tday

    Tday = FormatDateTime(date(),vbgeneraldate)

    SQL = "SELECT * FROM Ads WHERE Indate<" & Tday & " ORDER BY ID"

    Resulting in no postings found

    Whereas this

    SQL = "SELECT * FROM Ads WHERE Indate>" & Tday & " ORDER BY ID"

    returns every post in the database whether larger or smaller doesnt
    matter

    It seems the data reading is interpreted differently to how it presents
    itself.

    How can I set the SQL-statement to compare the dates correctly?


    Bob the ASP Builder

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Bob the ASP Builder Guest

  2. Similar Questions and Discussions

    1. Date comparison in a text data field
      I have a database column field defined as a text. I store dates in format: dd/mm/yyyy. The user passes a Start date search string in the same...
    2. Date comparison failure
      Does this qualify as an advanced technique? Sorry if not. This is a section of stock control I am doing to track supplier orders. I have a two...
    3. PhP, Access/SQL, Data comparison problem. (I'm new to PhP)
      Hi All! I'm fairly new to PhP and basicly trying to learn right now. Now I have a problem - I have a fairly large collection of movies which people...
    4. Date comparison and file download
      My goal, I would like to Compare the date of a file (one on the local drive, one on a remote server/url), if a newer resides on the server/url, then...
    5. Date comparison :: Original price vs Reduced price :: Access 2000/ASP
      I need some guidance in how to control dates with regards price reductions in my product list inside an Access 2000 database. For instance: 1....
  3. #2

    Default Re: Access SQL- Date comparison problem

    Bob the ASP Builder wrote:
    > I use an Access-database where one column stores a date originating
    > from this code:
    >
    > Indate = FormatDateTime(date(),vbgeneraldate)
    Totally unnecessary, but carry on.
    >
    > I then want to be able to show postings from the database being i.e.
    > smaller than current date.
    > So I use the current date from a code same as the above code and want
    > to compare with dates in the database.
    > The column in the database is in Date/time format and a posting from
    > today will read 2004-01-31
    You do realize that this has nothing to do with how the datetime value is
    stored ... or do you?

    Date/times in Access are stored as Double numbers, with the whole number
    portion representing the number of days since the seed date, and the decimal
    portion representing the time of day (.0 = midnight, .5 = noon)
    >
    > In my process page code I do this
    >
    > Dim Tday
    >
    > Tday = FormatDateTime(date(),vbgeneraldate)
    >
    > SQL = "SELECT * FROM Ads WHERE Indate<" & Tday & " ORDER BY ID"
    >
    Jet requires that date literals be delimited by hash marks (#):

    SQL = "SELECT * FROM Ads WHERE Indate>#" & Tday & "# ORDER BY ID"

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows Guest

  4. #3

    Default Re: Access SQL- Date comparison problem

    THANKS HEAPS!!

    Yes I realised the difference in stored value and presented value - but
    my tutorial was too incomplete to teach me the #-keys - IT ALL WORKS now
    - thank You

    Bob the ASP Builder

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Bob the ASP Builder Guest

Posting Permissions

  • You may not post new threads
  • You may not 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