Server side: search term is a date string but the database date is a timestamp?
Server side: search term is a date string but the database date is a timestamp?
jstolpe
Posts: 7Questions: 3Answers: 0
My setup:
- The start date is stored in my database as a timestamp like 1479794402.
- In the datatable it is formatted to "Apr 15th 2017" when displayed to the user.
Problem:
- User enters "Apr" in datatable search.
- How do I search the serverside datatable for this "Apr" string when it is stored as timestamp in the database?
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Most databases let you convert the stored date into almost any format as a string. You need to covert to the right format then check for "Apr"
If you are using server-side processing, then yes, you would need to convert the data submitted into something the server will be able to understand. Formatting the date using SQL functions as @bindrid suggests is a good way of doing that.
Allan
thanks all! I figured as much but figured I ask anyways.