|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
WHERE clause date syntax question
Hi i have a WHERE clause in my SQL statement, and I cant seem to get the right syntax for it. What I have is this:
3 variables: MonthDays ReportMonth ReportYear A datatable field: TheDate (a general date/time field) They are changing during the program, so I cant hardcode values. What I want is to retrieve data from a datatable on the conditions that: TheDate <= ReportMonth/MonthDays/ReportYear 8:59:59 AM AND TheDate >= ReportMonth/1/ReportYear 9:00:00 AM I am getting a syntax error with my current syntax (not shown) so I was hoping someone could tell me what the proper syntax would be. Thanks in advance! |
|
#2
|
||||
|
||||
|
Have you tried enclosing them in single quotes in your query:
TheDate <= 'ReportMonth/MonthDays/ReportYear 8:59:59 AM' AND TheDate >= 'ReportMonth/1/ReportYear 9:00:00 AM'
__________________
Up the Irons What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest Down with Sharon Osbourne Puzzle of the Month solved by sizeablegrin, etienne141 and L7Sqr, superior C/C++ programmers of the month |
|
#3
|
|||
|
|||
|
That gave me data type mismatch, sorry i forgot to say this above, i'm trying to execute this in VB6, so that makes a difference with the syntax...I'm not sure if its VB or the SQL itself that doesnt like my syntax so I thought I would try here first. Let me know if I should be over in the vb forum. Thanks!
|
|
#4
|
|||
|
|||
|
Problem Solved! i decided to make vb convert my variables to a date with help from the vb forum, thanks for the quick response!
|
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > WHERE clause date syntax question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|