FrontPage – Working with Date/Time data types

Working with Date/Time data types…

When trying to search a date/time field in your database you run into problems. This example will help you modify your FrontPage code to make it work.

So what is the problem? The issue arises because the text input box is sending it’s data in “text” format and the database wants date/time. There is no conversion taking place.

Here is what needs to happen to make the conversion; when inserting the date you want to search for in the text box, you surround the date with pound signs: #12/1/2000#. This converts the data type into date/time. Obviously, you don’t want to make your users do this so the example below shows you how to edit this into the FrontPage generated code so that the conversion takes place behind the scenes:

First, create your page with the database results region and a text search box that you want to use to search against a date/time field in your database.

Second, you will modify the code in HTML view. Look for a section of code similar to the code below, FrontPage should display this code as grey:

Find the line that begins with ‘s-sql’. In this code it is the following line:
s-sql=”SELECT * FROM Employees WHERE (HireDate = ‘::HireDate::’)”
Replace the single quotes around the names of any date fields with pound signs
as shown below. s-sql=”SELECT * FROM Employees WHERE (HireDate =
#::HireDate::#)” Save and preview the page and it should work.

Leave a Reply

Your email address will not be published.