Skip to main content
Participating Frequently
June 10, 2021
Question

Migrating from CF 4.5 to 2018 on MS SQL Server

  • June 10, 2021
  • 2 replies
  • 164 views

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.

 

    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    June 13, 2021

    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. 🙂

     

    Community Expert
    June 10, 2021

    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

    Dave Watts, Eidolon LLC
    Participating Frequently
    June 10, 2021

    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