• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Migrating from CF 4.5 to 2018 on MS SQL Server

New Here ,
Jun 10, 2021 Jun 10, 2021

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.

 

Views

122

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 10, 2021 Jun 10, 2021

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

Dave Watts, Eidolon LLC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 10, 2021 Jun 10, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 13, 2021 Jun 13, 2021

Copy link to clipboard

Copied

LATEST

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation