Results 1 to 3 of 3

Thread: SQL DateValue() : Datatype mismatch ... HELP!

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    4
    Hi alltogether,

    I knew, Access an VB had some Problems with empty DateFields, now I'm sure.

    I have got a table which contains some Date Fields, which can, but need not to be filled. Each month the ones with a Date older than TodaysDate will must be deleted.

    If I do the following SQL statement to select the records, I get a Datatype mismatch error.

    "SELECT * FROM tblTable WHERE DateValue(DateField) <= Date()"

    This Statement needs the DateValue() Function because otherwise I get Dates like 05.07.00 (with dd/mm/yy) when TodaysDate is 10.06.00. (because 5 is bigger than 10)

    Access is strange ... perhaps anyone can help me in my desaster?

    PS: The Select-Statement works! I tested it. Only if some Fields are Empty this Error occurs.

  2. #2
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    Hi maxx

    Why don't you check to see whether the column Is null first

    "SELECT * FROM tblTable WHERE DateField IS NOT NULL AND DateValue(DateField) <= Date()"

    That should sort out your problem

    Ian
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    4
    Nope, it does not ... it only does, if I create a query first "SELECT * FROM tblTable WHERE ... IS NOT NULL"

    But that's not what I want, because I would have to create tons of Querys just to delete them afterwards ... this would screw up my Database, because it's Access ...

    Thanks anyway, any further suggestions?

    maxx

Posting Permissions

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



Click Here to Expand Forum to Full Width