seach by days created

6 posts by 2 authors in: Forums > CMS Builder
Last Post: March 7, 2011   (RSS)

By 4cdg - March 3, 2011

Need to search section by number of days a record has been in the system.

kind of like a days on the market real estate search.

can i use createdDate or updateDate for that and how would i set up the search

Re: [4cdg] seach by days created

By Jason - March 3, 2011

Hi,

You could use either of those fields. The one you would choose would depend on exactly what type of results you're trying to return. Could you give an example of the type of search you would like to do?

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] seach by days created

By 4cdg - March 3, 2011

I want like to have a list called Days Listed where the choices are 1 day, 5 days, 1 week, 2 weeks, 1 month, 3months and each choice would search for the number of days old so a choice of 2 weeks would show all records that are 14 days old.

I would also like to know how to compare 2 dates so a user could enter 1 date and another date and it would list all records created on and in between those dates.

Re: [4cdg] seach by days created

By Jason - March 7, 2011

Hi,

In order to do this, you'll have to create custom "WHERE" clauses to do the search. You can use a MySQL function called DATE_SUB to get a date in the past

For example, if you wanted to get all records that are 14 days old, you could use something like this:

'where' => "createdDate = DATE_SUB(createdDate, 14 DAY)",

Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [4cdg] seach by days created

By Jason - March 7, 2011

Hi,

A good place to start would be to see if you can get the query working with hard coded values. Once you have that working, you can create your list and replace the hard coded value with a value submitted by your form.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/