Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > datetime use in custom query View modes: 
User avatar
Member
Member
tjadoon-gmail - 10/29/2010 4:07:36 PM
   
datetime use in custom query
I have a document type that has StartDateTime and EndDateTime fields. In my custom query i want to get only those items that are current meaning

Where GetDate() >= StartDateTime && GetDate() <= EndDateTime.

I am not able to use GetDate() in the query.

Also, i want to default StartDateTime and EndDateTime to GetDate(). In the attribute properties how can i accomplish this? Here i can only enter a fix date or click now or click calendar icon to select fixed date and time.

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 11/2/2010 8:31:39 AM
   
RE:datetime use in custom query
Hi,

1. You can replace getDate() method with a custom macro that returns requested date.
How to write and use the custom macro is described here:
http://devnet.kentico.com/docs/devguide/appendix_a___macro_expressions.htm

2. If you want set current datetime by default, you can insert following string into Attribute default value field in definition of your field in document type:
##TODAY## or ##NOW##

Another possibility is to write a custom form control.

Best regards,
Ivana Tomanickova