Datediff problem

Stimulsoft Reports.NET discussion
Post Reply
whythetorment
Posts: 20
Joined: Fri Nov 20, 2009 7:40 am

Datediff problem

Post by whythetorment »

Hi,

Im trying to do the equivalent of this in stimulsoft, but the result is coming back as -36
SELECT datediff(n, '2002-11-06 10:30:00.00', '2002-11-11 13:06:00.000')

The result in SQL is 7356

I've used this in stimulsoft :

DateDiff(DataSource1.ClaimDate, DataSource1.DteLastSent).Minutes

ClaimDate is '2002-11-06 10:30:00.00' and DteLastSent is '2002-11-11 13:06:00.000'

Thanks
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Datediff problem

Post by Jan »

Hello,

We use following code for DateDiff function:

Code: Select all

public static TimeSpan? DateDiff(DateTime? date1, DateTime? date2)
		{
			if (date1.HasValue && date2.HasValue)
				return date1.Value.Subtract(date2.Value);
			else
				return null;
		}
Unfortunately we can't change somthing now because this function is used in reports of our customers.

Thank you.
Brendan
Posts: 309
Joined: Sun Jul 16, 2006 12:42 pm
Location: Ireland

Datediff problem

Post by Brendan »

Hi,

you can try the following:

Code: Select all

{DateDiff(DataSource1.DteLastSent, DataSource1.ClaimDate).TotalMinutes}
This switches the order you pass in your date parameters and uses TotalMinutes instead of Minutes
whythetorment
Posts: 20
Joined: Fri Nov 20, 2009 7:40 am

Datediff problem

Post by whythetorment »

Thanks, the TotalMinutes option worked.
Post Reply