|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
sql query with visual basic
i have a problem with sql query with this code
dim Onedate as date Onedate = dateadd("m" , -1 ,date) adoSale.recordsource = "select * from tblSale where fldDate > " & OneDate adoSale.refresh dgdgrid1.refresh the problem that give me all the records. it's like i don't put a WHERE clause the data base is access 2000 and i work with visual basic 6.0 i got only a problem with query including a date thank for helping me jean-louis |
|
#2
|
||||
|
||||
|
Ok, You almost had it with the dateadd function you used in your VB code.
In sql server you should be unsing DateDiff(<timescale>, olddate, newdate) > 20 replace 20 with however days/months/years you wish to see. hope that helps |
|
#3
|
|||
|
|||
|
Quote:
thanks for the answer but i use access 2000 not sql server. I think the problem is in the query. Jean-louis |
|
#4
|
|||
|
|||
|
Try
adoSale.recordsource = "select * from tblSale where fldDate > #" & OneDate & "#"
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#5
|
|||
|
|||
|
Quote:
thank you Doug i think you give me the half of the solution because this code work adoSale.recordsource = "select * from tblSale where fldDate > #05-24-04#" but the problem with my OneDate it contains 24-05-04 the day before the month maybe it is the problem but i don't know how too fix it thanks again for the hint use ## jean-louis |
|
#6
|
|||
|
|||
|
If the date format doesn't match, it's the control panel - regional options- date configuration, just change it the to desired format.
|
|
#7
|
||||
|
||||
|
try just passing the date accross as a string.
Code:
adoSale.recordsource = "select * from tblSale where fldDate > '" & OneDate & "'" This usually works for me. I however would do this: Code:
adoSale.recordsource = "select * from tblSale where datediff(d, fldDate, " & OneDate & ")>0" |
|
#8
|
|||
|
|||
|
Try dis...
dim Onedate as date Onedate = dateadd("m" , -1 ,date) adoSale.recordsource = "select * from tblSale where fldDate > #" & OneDate & "#" let me know if dat works...am sorry cant chk at dis mo coz am at wrk Quote:
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > sql query with visual basic |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|