close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues


Search Database for Timestamp range

Thread began 10/01/2009 3:50 pm by bill173836 | Last modified 10/05/2009 5:44 pm by Eric Mittman | 1417 views | 3 replies |


Search Database for Timestamp range

Is it possible to search a timestamp field by a range. I timestamp each item that gets entered into the database and I want to view the item information based on a range of dates for instance.

I'd like to have 3 menus 1 each for (Date,Month,Year) and then set up the search like so:

Start Date: (Date,Month,Year) To End Date: (Date,Month,Year) Search ---> which then goes to a results page like you would get when using the DataAssist Wizard. I've tried using the DataAssist Search Wizard but it gives me Date Range (text field) To: (text field) (mm/dd/yyy) and it doesn't do anything when you click the submit button.


Sign in to reply to this post

Eric Mittman

Is your timestamp field stored in the traditional Unix style timestamp that is the number of seconds since 1970? If so then you should just be doing some basic number searches on the column and not date type searches.

The key to getting this to work properly is to make use of the date and time formatting functions in php. They are very robust and easy to use. Here is a general idea of how I implement searches like this.

First get it working with a single input field, you can update it after the fact to use the select lists like you mentioned.

When the user enters the value you will convert the string to a time stamp using the strtotime() function.

You then perform the search with this value since it should match the format in the db. The smaller the timestamp the further back in time it will be. So anything less than the entered time will be before it and anything equal to or greater than the entered time will be after it.

When you return the results on your results page you will need to make use of another function to format the date, it is simply the date() function. It will allow you to format a Unix timestamp in just about any way you would like. Here are some links to these functions pages on the php site for more info.



Please post back if you have any further questions or need any clarification on this.

Sign in to reply to this post


I'm using the timestamp function of mysql 5. So the value that is getting stored is like 2009-09-21 19:59:07 I'd be happy just to get the searchwizard to create 2 fields that give me the results I need. I can play around with the searching look and field later. I can't even get it to work using the search wizard. It creates to textfields to search by but doesn't do anything else.

Sign in to reply to this post

Eric Mittman

This type of date field in MySQL should be usable in the DataAssist Search server behavior to get back results.

To test it out try this, create a new page and add a recordset that will select all from this table that has the timestamp field. Once you have got the recordset crafted create the results display on the page and add the repeat region around it to show all of the records.

Next you will want to add a small form to the page, just something with an input and a submit button will do.

Now add in the DataAssist Search server behavior. In here configure the search to work on the time stamp column. For the criteria just choose date, for comparison choose less than, and for the type choose edit. For the Edit field name use the lightning bolt to select the text field of the form you just added. Double check the settings before clicking on ok.

When you test this you should be able to enter a valid date into the text field and have all of the records with a date that is previous to this show in the results. Please post back with what you get.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...