Hey,

Would it be possible to add a data type of 'date'?

I am using computed field to calculate dates in the future dependent on other dates entered on a form, it works great.

I want to report on my computed fields using views and expose filters to the user. However due to the computed field not being 'date' I do not have the correct options available to me that I do have when the field is of date type.

Thanks

Comments

staff_whyte’s picture

I got around this by using rules to populate a date field.

jazznight17’s picture

I got around this by using rules to populate a date field.

could you explain me how did you do that please ?

staff_whyte’s picture

Create your date fields in your content type, origionaldate and mynewdate
Create a rule to fire after saving new content or updating existing content.
Make it only happen on the correct content type using the condition.
Create an action that sets the value in mynewdate to origionaldate +/- your value, you can do it in various increments like minutes, days etc..

Gaofengzzz’s picture

I have some problem in my site, any other idea or patch?

colan’s picture

Status: Active » Closed (won't fix)

Sorry, this is out of scope, but yes, you can use hooks or Rules to act on a Date field.

nancydru’s picture

Issue summary: View changes
Priority: Major » Normal
Status: Closed (won't fix) » Active

I don't understand how this is out of scope. Clearly many people want this, me included. Requests even go back to 5.x. There are many reasons why date-type computed fields are valuable.

nancydru’s picture

Without this, Views filtering is not possible.

colan’s picture

Fair enough. Patches welcome!

jmuzz’s picture

Status: Active » Needs review
StatusFileSize
new4.26 KB

Here's some date support. Briefly tested filtering and sorting in views.

  • This will add datetime data type option, but only if the date module is installed.
  • Requires date_views (packaged with date) to use date related views features.
  • Can only store datetime values (so no Unix timestamps or ISO formatted dates)
markabur’s picture

Here's a reroll of #9.

I'm using this with views, search_api, and facet_api. The date facets work as expected, with the ability to drill down by year, month, and day.

ajlow’s picture

Does someone have a similar solution for the the 3.0@alpha branch?

From what I can see, it seems it should be done by this method: https://www.drupal.org/docs/drupal-apis/entity-api/dynamicvirtual-field-... however I am having trouble having the field displayed...