Print Page | Close Window

Subtract Integer from DateTime

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=4300
Printed Date: 06 May 2024 at 1:16pm


Topic: Subtract Integer from DateTime
Posted By: Alldaypilot
Subject: Subtract Integer from DateTime
Date Posted: 18 Sep 2008 at 7:16pm
 
I have one database field that stores a datetime.  I have another one that stores an integer value (represents minutes).
 
How can I write a formula that takes the datetime, subtracts the integer(minutes), and gives me the new datetime?



Replies:
Posted By: Savan
Date Posted: 18 Sep 2008 at 11:17pm
you can use this function
 
Dateadd("n",(<integer>*-1),{@tday})
 
where n stands for minutes to be added or subtract
 
(<integer>*-1)  is the no of minutes (table field name)  to be subtracted
 
mailto:%7b@tday - {@tday } is the date from which the minutes to be subtracted.
 
You can find many more such inbult  functions of crystal reports in chapter 6 "Programming with Crystal Syntax" of  Brians Bischof book " Crystal Reports Encyclopedia"


-------------
Thanks
Savan


Posted By: Alldaypilot
Date Posted: 19 Sep 2008 at 9:18am
Thanks!  That worked.
 
I was actually playing with Dateadd yesterday but couldn't get it working right.



Print Page | Close Window