Get conmputed column with date difference from typed List

Posts   
 
    
wexa
User
Posts: 38
Joined: 27-Jul-2007
# Posted on: 12-Apr-2008 03:45:52   

Hello, I have a database that I can only read, that for I have not used VIews or stored procs to get this.

I have a log table for costumers, and I must compute the elapsed time since the last time the costumer got a service, in SQL I got this working (I am computing the elapsed time in minutes and hours).


SELECT   P.*, DATEDIFF([minute], CAST(C_Date + ' ' + C_Time AS datetime), GETDATE()) AS difMinutes, DATEDIFF([hour], 
                      CAST(C_Date + ' ' + C_Time AS datetime), GETDATE()) AS difHours
FROM         CustomerState P
WHERE    (Id =
                          (SELECT    TOP 1 P1.Id
                            FROM          CustomerState AS P1
                            WHERE     P1.Customer_Id = P.Customer_Id
                            ORDER BY P1.C_Date DESC, P1.C_Time, P1.Id DESC))
ORDER BY Customer_ID

I have made a typed list and tryed to group and get a MAX but I am stocked, I would like to know if there is a better approach for this.

Regards

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 12-Apr-2008 05:38:02   

Hi wexa. I would go on DynamicList, but even with TypedList is possible. Could you please post the code you are using and the typedView fields?

David Elizondo | LLBLGen Support Team
wexa
User
Posts: 38
Joined: 27-Jul-2007
# Posted on: 12-Apr-2008 07:01:34   

Thank you David

I am attaching the view, the code I use is just to load an ASP Grid.

I am trying to extend the properties to compute the DateDiff, but my problem is in the grouping.

Will try to make it compile during the day to see if I can post if I have made advance.

Gracias!

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 12-Apr-2008 23:26:13   

I think you forgot the attachment.

wexa
User
Posts: 38
Joined: 27-Jul-2007
# Posted on: 12-Apr-2008 23:34:32   

Sorry, it is here

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 13-Apr-2008 20:46:39   

Hi wexa, I can't see your custom code where you set the appropiate expressions to the TypedList. To make things easier, you could set the expressions outside the TypedList (at your own BL or GUI code), then you can pass a groupBy clause to the TypedList fetch.

Check this out: - LLBLGenPro Help -> Using the generated code -> Using TypedViews, TypedLists and DynamicLists -> Using GROUP BY and HAVING clauses. - http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=10472&StartAtMessage=0&#58286

David Elizondo | LLBLGen Support Team