Developer forum

Forum » Feature requests » Item publisher date filters

Item publisher date filters

Nuno Aguiar
Reply

Hi,

 

Would be nice if for date fields we could set up validation like Date is @Code("Today") instead of a fixed date/time.

 

Best Regards,

Nuno


Replies

 
Morten Bengtson
Reply

Hi Nuno,

Instead of the string "Today" you need to specify some C# code that evaluates to a DateTime. Try this...

Field Condition Value
Date Is @Code(DateTime.Today)

 

You can even add or subtract days, months or years if you like. See DateTime for details.

 
Jan Sangill
Reply

Hi Morten,

But if you have a datetime field, you will get a datepicker to use.

Will your suggestion work in the datepicker?

 
Morten Bengtson
Reply

It worked for me. Try it out :)

When you click inside the date field a date picker will appear, but you can also enter a value directly in the field. You might need to select a date first and then enter a value afterwards in order to avoid the date picker.

 
Jan Sangill
Reply

Hmm nice:)

I guess its another thing though with the date and time field?

But I can see it working on the datefield only, as you say.

 
Nuno Aguiar
Reply

Hi Morten,

 

Thanks, then I would like to change my feature request to have this be a little bit more user friendly :p

 

Best Regards,

Nuno

 
Hans Ravnsfjall
Reply

Is it also possible to set filter up using @Code() or similar, where you can test if either a valid to date is After today, or if the Date field is empy?

 

Someting like:

DateTo is after @Code.Date.Time.today

or

DateTo.IsNullOrEmpty

Can this be done in some way?

 
Nicolai Høeg Pedersen
Reply

Hi Hans

Not sure Dynamicweb items supports 'nullable' dates. But you simply create two filters - one checking the date and the other checing for the empty string - and combine them using OR under the filtering section.

 
Hans Ravnsfjall
Reply

Ok, thank you Nicolai

Then one of them would be Date is @Code(DateTime.Today)

what would the other look like? Date is ???

thanks for the help

regards Hans

Field Condition Value
Date Is @Code(DateTime.Today)

 

- See more at: http://developer.dynamicweb.com/forum/feature-requests/feature-requests/item-publisher-date-filters.aspx#sthash.1IhBJqFF.dpuf
Field Condition Value
Date Is @Code(DateTime.Today)

 

- See more at: http://developer.dynamicweb.com/forum/feature-requests/feature-requests/item-publisher-date-filters.aspx#sthash.1IhBJqFF.dpuf
 
Nicolai Høeg Pedersen
Reply

Depends on what you want to do

But it would be "Date" "is after" "@Code(DateTime.Today)" or "date" "is" ""

 
Hans Ravnsfjall
Reply

Ok

So I´ll just have to leave the field empty

I´ll try that thank you

regards, Hans

 

 
Hans Ravnsfjall
Reply

Unfortunatly I can not leave the field empty. It automatically fills inn todays date, if i try to save an empty date field http://screencast.com/t/ppFD0ZDcAiB

 
Nicolai Høeg Pedersen
Reply

Then make sure the field has a value on creation so you have something to test against in your filter settings.

BR Nicolai

 
Hans Ravnsfjall
Reply

But that is the point. I want to test if the Datefield is empty/undefined. But that can´t be done it seems. It is on this page that I try to set the filter http://leinkjan15.net.dynamicweb-cms.com/Default.aspx?ID=8971&Purge=True

 

 
Nicolai Høeg Pedersen
Reply

You can set the default value to a specific date - i.e. 1/1-2015 and you can use that value to test against. The best I can do.

 
Hans Ravnsfjall
Reply

Ok, thank you Nicolai. I will post a feature request for making it possible to test if a datefield is empty/undefined:

 

Regards, Hans