Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> DbFunctionCall in Predicate
 

Pages: 1
LLBLGen Pro Runtime Framework
DbFunctionCall in Predicate
Page:1/1 

  Print all messages in this thread  
Poster Message
tprohas
User



Location:
Tucson, AZ
Joined on:
23-Mar-2004 00:00:43
Posted:
257 posts
# Posted on: 02-Nov-2010 21:40:36.  
I am having a hard time trying to figure out how to write this query. Can anyone help?

I'm trying to convert the following SQL into a predicate.

/*
Display 14 days after activated date.
10/14 + 14 = 28 - Show on the 28th.
Remove from display 28 days after activated date.
*/
WHERE (GETDATE() >= DATEADD(DAY, 14, [ActivatedDate])
AND GETDATE() <= DATEADD(DAY, 28, [ActivatedDate]))
Aaron Prohaska
http://www.verdesoft.com/
 
Top
MTrinder
User



Location:
London by day, Milton Keynes by night.
Joined on:
08-Oct-2008 17:55:47
Posted:
1461 posts
# Posted on: 02-Nov-2010 22:28:26.  
Hi

Can you show us what you have got so far, and explain why it is not working...?

Matt


  Top
tprohas
User



Location:
Tucson, AZ
Joined on:
23-Mar-2004 00:00:43
Posted:
257 posts
# Posted on: 03-Nov-2010 20:01:44.  
OK, I finally figured this out. Here is what I did.

Code:

DbFunctionCall getDate = new DbFunctionCall("GETDATE", new object[] { });
DbFunctionCall dateAddStart = new DbFunctionCall("DATEADD(DAY, 14, {0})", new object[] { NominationFields.ActivatedDate });
DbFunctionCall dateAddEnd = new DbFunctionCall("DATEADD(DAY, 28, {0})", new object[] { NominationFields.ActivatedDate });
IPredicate startDayFilter = (NominationFields.ActivatedDate.SetExpression(getDate) >= dateAddStart);
IPredicate endDayFilter = (NominationFields.ActivatedDate.SetExpression(getDate) <= dateAddEnd);
PredicateExpression dayFilter = new PredicateExpression();
dayFilter.AddWithAnd(startDayFilter);
dayFilter.AddWithAnd(endDayFilter);
filter.PredicateExpression.AddWithAnd(dayFilter);
Aaron Prohaska
http://www.verdesoft.com/
 
Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8060 posts
# Posted on: 04-Nov-2010 06:04:57.  
Congrats Regular Smiley

David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.