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

getting records older than 30 days from the current date

New Here ,
May 17, 2006 May 17, 2006

Copy link to clipboard

Copied

I am using MS SQL 2000 how can I fetch the data which are older than 30 days from the current date? i set currendate field to "datetime" as a data type and length is "8"

<cfset variables.getdate = DateAdd('d',-30, now())>

select dataname
from tabletest
where currendate >= 'variables.getdate'

the above sql stmt does not work.
TOPICS
Advanced techniques

Views

572

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

correct answers 1 Correct answer

Enthusiast , May 17, 2006 May 17, 2006
select dataname
from tabletest
where currendate <= #CreateODBCDate(dateAdd("d", -30, Now()))#

You say you want records that are older than 30 days from now, thus it should be less than or equal to the date
But if you want records from 30 days ago till now then it should be greater than or equal to

Ken

Votes

Translate

Translate
Enthusiast ,
May 17, 2006 May 17, 2006

Copy link to clipboard

Copied

select dataname
from tabletest
where currendate <= #CreateODBCDate(dateAdd("d", -30, Now()))#

You say you want records that are older than 30 days from now, thus it should be less than or equal to the date
But if you want records from 30 days ago till now then it should be greater than or equal to

Ken

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
LEGEND ,
May 17, 2006 May 17, 2006

Copy link to clipboard

Copied

LATEST
Change variables.getdate to getdate, or whatever the name of the mssql function is that returns the current date and time. You don't need cold fusion variables or functions for this.

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