Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: dateadd Post Reply Post New Topic
Author Message
cfrey
Groupie
Groupie


Joined: 06 Feb 2008
Location: United States
Online Status: Offline
Posts: 55
Quote cfrey Replybullet Topic: dateadd
     Posted: 06 May 2008 at 8:10am
I'm trying to calculate the last day of the previous month from a parameter. Here is my code:

dateadd("M", -1,{?ReportDate})

If the report date was April 30, 2008 the above returns March 30, 2008. I need to return  March 31, 2008.

Your help is appreciated.

Thanks.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 06 May 2008 at 9:56am
Try something like this:
 
date(year({?ReportDate}), month({?ReportDate}), 1) -1
 
-Dell
IP IP Logged
cfrey
Groupie
Groupie


Joined: 06 Feb 2008
Location: United States
Online Status: Offline
Posts: 55
Quote cfrey Replybullet Posted: 06 May 2008 at 1:20pm
That worked. I can't thank you enough.

I thought dateadd took the change in month ends into account. I guess I was very wrong.

Thanks again for your help.
IP IP Logged
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