home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 9,379 of 10,840   
   Max Healey to All   
   Re: Date Error   
   02 Apr 05 21:50:44   
   
   From: bill@busdriver.com   
      
   Should be   
      
   cmdQuery.CommandText = "SELECT * from tblTimings WHERE   
   fldDate = #" & dtpDate.Value & "#"   
      
   That is if you are in the USA Europe and Australia will need to do this to   
   ensure consistent results   
      
   cmdQuery.CommandText = "SELECT * from tblTimings WHERE   
   fldDate = #" &dtpDate.month & "/" & dtpDate.day & "/" dtpDate.year  & "#"   
      
   SQL Process dates in US Date Format but will not throw an error if you feed   
   it dd/mm/yy instead it try's to fix it for you so it 1/4/05 will give be   
   processed as 4 January where as 13/4/05 will be processed as 13 April go   
   figure !   
      
      
      
      
    wrote in message   
   news:1110960446.350093.325760@g14g2000cwa.googlegroups.com...   
   > Hello:   
   >   
   > I have an access database that stores employee timings by date.   
   > At the same time, I have a form that queries this database.   
   > On the form I use a DTpicker to enable a user input the date for which   
   > he/she wants data   
   > When I execute the query below in my VB code, I get a run time error   
   > that says   
   >   
   >   
   > Error ===> "Datatype mismatch in criteria expression."   
   > Query ===> cmdQuery.CommandText = "SELECT * from tblTimings WHERE   
   > fldDate = '" & dtpDate.Value & "'"   
   >   
   >   
   >   
   > I don't understand why I get this error when   
   > both, the field fldDate is of type Date/time and dtpDate.Value returns   
   > the same. I tried setting both the DB date and the control date to   
   > different date formats such as short date, long/general date, custom   
   > date, but I still get the same error.   
   >   
   >   
   > Appreciate any help on resolving this   
   >   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca