|
-
December 22nd, 2003, 02:52 PM
#1
Sql
I am having a problem with my SQL statement...
Code:
stry = "Select * from TabCheckHistory where ClientId = '" & CID & "'"
stry = stry & " and Format(CheckDate,'YYYY') = " & LastYear
I guess I can't use the format function in SQL????
http://www.dewgames.com
Shareware and Free games!
-
December 22nd, 2003, 04:53 PM
#2
Currently your sql statement reads like this:
stry = "Select * from TabCheckHistory where ClientId = '12345' and 2003 = 2003
I think what you want is
stry = "Select * from TabCheckHistory where ClientId = '" & CID & "'"
stry = stry & " and DatePart('yyyy', checkdate) = '" & LastYear & "'"
Be nice to Harley riders...
-
December 22nd, 2003, 11:26 PM
#3
DatePart function returns int...
Hi,
DatePart function returns 'int' as its' output type. So the above posting should change like this...
stry = "Select * from TabCheckHistory where ClientId = '" & CID & "'"
stry = stry & " and DatePart('yyyy', checkdate) =" & LastYear
Also note that this SQL statement can only be used with SQL Server and Access.
__________________
- Buddhi from Sri Lanka -
- Paradise of Sinhalese/Buddhists -
-
December 22nd, 2003, 11:45 PM
#4
Very true - I added the single quotes in because sql server (and access) will do an implicit conversion (yes...I can be a bad programmer from time to time...) and this way you wouldn't have to cast the text of your input box.
Buddhi's way is clearly more correct...and I'm lazy
Be nice to Harley riders...
-
December 23rd, 2003, 12:11 AM
#5
You are welcome...
Thanks two dogs....
Anyway to improve my post you have given me the basis..
__________________
- Buddhi from Sri Lanka -
- Paradise of Sinhalese/Buddhists -
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|