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?

jstolpejstolpe 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:

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119
    Answer ✓

    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"

  • allanallan Posts: 63,889Questions: 1Answers: 10,530 Site admin
    Answer ✓

    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

  • jstolpejstolpe Posts: 7Questions: 3Answers: 0

    thanks all! I figured as much but figured I ask anyways.

This discussion has been closed.