Print Page | Close Window

Help with a Date Formula

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2022
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=767
Printed Date: 04 May 2025 at 6:32pm


Topic: Help with a Date Formula
Posted By: WCrew04
Subject: Help with a Date Formula
Date Posted: 30 May 2007 at 12:00pm
I have been trying to make a formula that will take a date field and display the last date of the month but can't get it to work and am getting very frustrated.
 
For example, if the date field is 05/25/2007 I want the formula to display 5/31/2007.
 
Any help would be greatly appreciated. Thanks!



Replies:
Posted By: BrianBischof
Date Posted: 30 May 2007 at 2:17pm
I think there is a better formula than this one, but it escapes me rght now. Sorry.
//Get the first day of the next month
x := DateAdd("m",1,Date(Year(field),Month(field),1));
//Subract one day from it.
x := DateAdd("d", -1, x);



-------------
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>



Print Page | Close Window