Friday, February 17, 2012

Datediff problem

I'm trying to use the same select statement I used in classic SQL, but it isn't working. I get a "The server tag is not well formed." error.

I'm trying to return all the records where the date in a particular field are over 60 days old. My select statement is:

"SELECT [ReNewAd], [Male or Female], [File2], [PHOTO], [First Name], [Last Name], [City], [State], [NewAd] FROM Members Where ('NewAd' IS NOT NULL AND (DateDiff('d', [NewAd], '" & Now() & "') <= 60)) order by [NewAd] Desc"

I've been looking through the datediff posts, but I'm not making any sense of what I'm reading. Can anyone see what I'm doing wrong?

Thanks, Diane

hi Diane,

"The server tag is not well formed" error usually comes when browser is not able to render HTML as far as I know like some tag etc misses.

could you tell me when are you getting this error.

thanks,

satish.

|||

Presuming VB.Net.

Is the statement on One or two lines? If multiple lines you must use line continuation.

"SELECT [ReNewAd], [Male or Female], [File2], [PHOTO], [First Name], [Last Name]," & _

" [City], [State], [NewAd] FROM Members Where ('NewAd' IS NOT NULL AND" & _

" (DateDiff('d', [NewAd], '" & Now() & "') <= 60)) order by [NewAd] Desc"

Rgds,

Martin.

|||

Server Tag. Attribute assignment must all be on one line. Presuming Now() is a known function for returning the Date as text; it looks ok.

|||

Your WHERE clause has problems.

Try this:

"SELECT [ReNewAd], [Male or Female], [File2], [PHOTO], [First Name],[Last Name], [City], [State], [NewAd] FROM Members Where (NewAd ISNOT NULL AND DateDiff("d", NewAd, getdate()) <=60)) order by [NewAd] Desc"

|||

Thanks everyone! It's working!

Diane

No comments:

Post a Comment