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

query of query for two dates

Explorer ,
Jun 08, 2006 Jun 08, 2006

Copy link to clipboard

Copied

I am trying to query the database for a given date and the next nearest older date within 28 days. This is what I have tried but it isn't assigning anything to DD1 and DD2. i have tried a number od other things but i am stumped.


<cfquery name="getdatedata" datasource="dairy">
SELECT MAX(std.DataDate) as DD1,
MIN(std.DataDate) as DD2,
DateDiff(d, MIN(std.DataDate), MAX(std.DataDate)) AS DDiff
FROM
(select top 2 datadate
FROM dairy.dbo.paddockdata
WHERE FarmId='#form.farmid#'
AND datadate between #datevalue#
and dateAdd("d", -28, #datevalue#)
ORDER by datadate DESC) AS std
</cfquery>
TOPICS
Advanced techniques

Views

300

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

Advisor , Jun 08, 2006 Jun 08, 2006
AND
( datadate between dateAdd("d", -28, #datevalue#) <!--- smallest value first. --->
and #datevalue#
)

Votes

Translate

Translate
Advisor ,
Jun 08, 2006 Jun 08, 2006

Copy link to clipboard

Copied

AND
( datadate between dateAdd("d", -28, #datevalue#) <!--- smallest value first. --->
and #datevalue#
)

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
Explorer ,
Jun 09, 2006 Jun 09, 2006

Copy link to clipboard

Copied

LATEST
How simple! Thanks!

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