Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
bbxrider
Starting Member
37 Posts |
Posted - 2010-04-28 : 11:49:01
|
| This statement is not workingstrSQL = " SELECT * FROM orientationData where orientationDate > " & 'postDate'postDate is set up withpostDate = "04/28/2010" (this eventually will be a date from a web form)postDate = CDate(postDate)since I can't change how the db date field is used in the select, I must need to do something to the variable? or change the syntax in the select statement? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-28 : 11:51:50
|
| is postdate of type datetime------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-04-28 : 12:21:18
|
| If the postDate is of datetime datatype then you can directly substitue the variable.In case it is of varchar type then you need to convert it to datetime.Example:select Convert(datetime,'04/28/2010',101)Regards,BohraI am here to learn from Masters and help new bees in learning. |
 |
|
|
bbxrider
Starting Member
37 Posts |
Posted - 2010-04-28 : 12:33:06
|
| this is traditional asp, not asp.netoriginally I created postDate like thisdim postDatepostDate = "04/28/2010"postDate= CDate(postDate)and with this postDate works in the asp dateDiff functionsince the post asking if postDate was a datetime variable I tried this but it also did not workdim postDatedim dateWorkpostDate = "04/28/2010"dateWork = CDate(postDate)strSQL = " SELECT * FROM orientationData where orientationDate > " & dateWorkbtw, the result recordset includes all the recs, no matter what the date is |
 |
|
|
bbxrider
Starting Member
37 Posts |
Posted - 2010-04-29 : 02:36:00
|
| finally found the answer, since this is an access db, literal dates need to be surrounded by ##, similar to asp date field, eg, dim aDateaDate =#04/28/2010# 'eliminates need to do a cdate functionand similar to sql server using ''so the sql string is constructed thus" SELECT * FROM orientationData where orientationDate > #" & postDate & "# and EmailSentCount < targetAttendeeCount" |
 |
|
|
|
|
|
|
|