Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: YTD through end of last month Post Reply Post New Topic
Author Message
JRSmith
Newbie
Newbie


Joined: 10 Aug 2012
Location: United States
Online Status: Offline
Posts: 3
Quote JRSmith Replybullet Topic: YTD through end of last month
    Posted: 10 Aug 2012 at 10:27am
I need to select records based on a date range that starts with January 1 of this year and runs through the last day of last month (based on the current date).
 
I also need to select the same date period for the previous year.
 
Thanks in advance for your help.
IP IP Logged
z9962
Senior Member
Senior Member
Avatar

Joined: 04 Jul 2012
Online Status: Offline
Posts: 161
Quote z9962 Replybullet Posted: 13 Aug 2012 at 3:02am

//last day of month
//Date(DateAdd("d",-day(today),DateAdd("m",1,today)))

//First day of year
//date(year(today),1,1)

//last day of month last year
//Date(DATEADD("yyyy",-1,DateAdd("d",-day(today),DateAdd("m",1,today))))

//First day of previous year
//date(year(today)-1,1,1)

therefore
(
[datefield] in date(year(today),1,1) to Date(DateAdd("d",-day(today),DateAdd("m",1,today)))
or
[datefield] in date(year(today)-1,1,1) to Date(DATEADD("yyyy",-1,DateAdd("d",-day(today),DateAdd("m",1,today))))
)
IP IP Logged
JRSmith
Newbie
Newbie


Joined: 10 Aug 2012
Location: United States
Online Status: Offline
Posts: 3
Quote JRSmith Replybullet Posted: 13 Aug 2012 at 10:24am
Thanks for your help.  A little tweeking in my report and it worked.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.033 seconds.