Copy link to clipboard
Copied
Migrating a few websites from CF 4.5 to 2018 (I know!) and could use some assistance. Seems CF 2018 doesn't like my syntax:
<cfquery name="CalCount" datasource="#dsn#">
SELECT ID FROM Calendar
WHERE Approved = 1
AND Caldate > #now()# -1
AND WebsiteID=#application.WebsiteID#</cfquery>
Seems #now()# converts to{ts '2021-06-10 07:26:22'}
SELECT ID FROM Calendar WHERE Approved = 1 AND Caldate > {ts '2021-06-10 07:26:22'} -1 AND WebsiteID=1
CF doesn't seem to like my syntax. Will be digging into dates and formatting, but any insights appreciated.
Copy link to clipboard
Copied
Holy crap, I'm surprised that's the only thing that doesn't work!
I would look at the DateDiff function in CF as the easiest resolution for this. I don't think you'll have to worry about formatting that way.
Dave Watts, Eidolon LLC
Copy link to clipboard
Copied
Thanks Dave, Yep its pretty amazing, but just about everything is working. My code is fairly straight forward - basic queries, if/then statements, setting variables, etc. Believe it or not 99% of it is working like a charm! I'm sure there are a few bugs I'll find along the way, but generally everything is working well. Thanks for your input. Cheers!
Chuck Ebbets
Copy link to clipboard
Copied
You should use MS SQL's own date-functions. For example, in MS SQL,
dateadd(day, -1, getdate())
represents the date of yesterday. That way, you will solve the problem once and for all for any ColdFusion version. 🙂