|
Subject:
|
Searching datetime field
|
|
Posted By:
|
SoC
|
Post Date:
|
10/28/2004 11:26:20 PM
|
Hi,
I have a SQL database table with a datetime field in dd/mm/yyyy format.
I have a web page that allows users to search this database.
How do you search a datetime field?
i.e., I want users to be able to enter a date into a text field that will search the database.
I know it's not as simple as saying SELECT * FROM TABLE WHERE dateField = theTextFieldVariable.
Any help much appreciated
S
|
|
Reply By:
|
shahchi1
|
Reply Date:
|
10/29/2004 11:12:51 AM
|
what's problem with "SELECT * FROM Table WHERE dateField = 'dd/mm/yyyy'?
You can also search date range using "BETWEEN' and "AND" predicate. For e.g. ..WHERE dateField BETWEEN 'your_start_date' AND 'your_end_date'
|
|
Reply By:
|
happygv
|
Reply Date:
|
10/29/2004 10:38:00 PM
|
Hi SoC,
Whatever the date format being used in the frontend, convert it to a format that is similar to that od the date in database. Else use a standard format throughout the application. When dd/mm/yyyy is the format used in DB, you can use the same from the frontend too. Otherwise, follow the "yyyy-mm-dd" format.
Post here if you face any problem in doing so.
Cheers!
_________________________ - Vijay G Strive for Perfection
|