AnsweredAssumed Answered

SQL to find date range

Question asked by jtorpy on Feb 27, 2018
Latest reply on Feb 27, 2018 by okramis

I've got the info below as part of an ExecuteSQL statement in a chart (delimited data). It was working fine with just 'month' and I've broken it adding the Year info. (year and month are separate, not as a date).

 

YrMon is a calculated (with storage) field, example "2017-Jan".

Yr (number), Mo (number) are in the same table and not calculated.

YrMon used to say "Month" which is also a non-calculated field, example "JANUARY"

The globals table is not related in ERD.

It was working with just Month, but now it doesn't seem to be working with the Year conditions...

ps. ORDER BY Mo should be "ORDER BY Yr, Mo" I think, but I didn't want to complicate it with that right now.

 

SELECT DISTINCT \"YrMon\"

FROM impDataRpt

WHERE Yr >= ?

AND Mo >= ?

AND Yr <= ?

AND Mo <= ?

ORDER BY Mo";"";""; tblGlobals::g_YrStart; tblGlobals::g_MoStart ; tblGlobals::g_YrEnd; tblGlobals::g_MoEnd)

 

Thanks for taking a look.

Outcomes