problem with date type. please help

vb6 Benin
  • 14 years ago

       I'm working on a VB project with Access database. I encounter a problem when

    trying this query: "Select * from [COMMAND]  where datcde=" & txtdatcde, adopendynamic

    txtdatcde is a textbox control and it contain a date

    datcde is the table COMMAND 's attribute on date type with the following mask "00/00/0000".

    the query return no row.

    Unfortunatly, if i change the property datcde's type to Text all things go right. But further operation

    request this attribute to be of date type.

       I welcome any idea. Help please

  • 14 years ago
    Hi Kikidevfus

     Actually this problem may occur when ur regional date settings date format.

    If ur regional settings format is like "mm/dd/yyyy" or  "m/d/yyyy" then ur input given by vb also treat like "mm/dd/yyyy". In this time if u give "31/10/2000" and then convert into date cdate("31/10/2006") ur system will give error.

    If u overcome this problem u always pass ur input in the "dd/MMM/yyyy" format only.

    I hope this will solve ur problem.

    Hari K

  • 14 years ago

    I'm sorry if this doesn't apply when using a command but try enclosing the date with hashes: "Select * from [COMMAND]  where datcde = #" & txtdatcde & "#" & , adopendynamic

  • 14 years ago

                                           Thank to hari and sync_or_swim!

         My date settings is on "dd/mm/yyyy" format. and whenever i change this to "mm/dd/yyyy". there is no change.

        Concerning sync_or_swim's solution that 's the first tips i tried. but no thing to do. So i'm still looking for others solutions to solve this problem. hoping to hear from you.



  • 14 years ago

    You can do one thing, remove the mask and then try...

  • 14 years ago

    Hi kikidevfus

    are you sure you changed the data value of your textbox into date?


  • 14 years ago

                       Thanks to every  body. The problem is simple. I've just change the date format mask in my database; i move it from "00/00/0000;;" to "00/00/0000" and then i've no problem.

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves” - Alan Kay