Print Page | Close Window

YearToLastMonth possible?

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=533
Printed Date: 18 May 2024 at 8:38pm


Topic: YearToLastMonth possible?
Posted By: Rick
Subject: YearToLastMonth possible?
Date Posted: 17 Apr 2007 at 12:39am
Hi,
 
Is it possible to make a selection which contains all data in the period January 1st - last day of previous month? The standard list of periods doesn't seem to have this option.
 
Thanks!



Replies:
Posted By: BrianBischof
Date Posted: 17 Apr 2007 at 9:08am
You have to create a custom date function to handle the last day. This calculates the first day of the current month and then subtracts one day.
DateAdd("d", -1, Date(Year (CurrentDate), Month(CurrentDate), 1)-1)



-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: Rick
Date Posted: 18 Apr 2007 at 1:50am
Thanks,
 
As I am new in Crystal and programming in general, I am having trouble creating the custom function.
I figured the YearToLastMonth function would not need variables, as CurrentDate is the only relevant date in both January 1st of this year and last day of last month.
Anyway, Crystal asks me for variables and gives me a lot of errors when I am trying to make the function.
 
Any suggestions on how to create it, please? Thanks in advance!!



Print Page | Close Window