Skip to main content
May 26, 2009
Answered

Display query for current and previous month

  • May 26, 2009
  • 2 replies
  • 1064 views

I have a query that I am working with in which I have a month and year field where I would like to display the current month and previous months information just not quite sure how to make this work.

My table rows look like this

  • nMonth
  • nYear
  • nDetail
  • nImg
  • nLink

I have looked over all of Coldfusions Date Functions and several articles that are similar but not sure how to tie this all together.

This topic has been closed for replies.
Correct answer Dan_Bracuk

These variables should get you started.

year1 = year(now());

month1 = month(now());

year2 = year(DateAdd("m", -1, now()));

month2 = month(DateAdd("m", -1, now()));

You can figure out how to use them in your query.

2 replies

Dan_BracukCorrect answer
Inspiring
May 26, 2009

These variables should get you started.

year1 = year(now());

month1 = month(now());

year2 = year(DateAdd("m", -1, now()));

month2 = month(DateAdd("m", -1, now()));

You can figure out how to use them in your query.

May 26, 2009

Thank You for your help on this

May 26, 2009

Are you wanting to query the data for the current month and previous month using the nmonth a nyear fields?