0

Is there any way to insert java-script function between the query ??

For example :: In an query, i have stored date of birth like this 10101990 in the database, it means 10/10/1990, but I have display it in-front of page but in certain format like 10.10.1990 by using one java-script function.

Please suggest me any way ??

Rubyist
  • 6,486
  • 10
  • 51
  • 86
  • 1
    Can you please clarify what you are doing? How does Javascript come into play in a SQL query? – Pekka Oct 12 '10 at 12:10
  • Sorry Guys, I have given an generalized example. Actual format is like this. 1234567890, now i have an function which will convert the above statement into 1234.56.7890 & In database, 1234567860 is stored. But during display, I can use this function but issue is that i have to use this in between sql query ?? – Rubyist Oct 12 '10 at 12:32
  • Can you give a concrete example? The one in your question and the one in your question don't give a complete picture – Nivas Oct 12 '10 at 12:59
  • why not just something like SUBSTRING: SUBSTRING(FieldName, 1, 4) || "." || SUBSTRING(FieldName, 5, 2) || "." || SUBSTRING(FieldName, 7) – Leslie Oct 12 '10 at 17:49

2 Answers2

1
  1. You should not be storing date as a string on the database. This might have a lot of issues. You have to store date as, well, a Date
  2. You have to fetch this using a query using a language like Java or PHP.
  3. When you get the date in the screen, you can format it in javascript, if required. However you can format it in PHP or Java. For java see SimpleDateformat.

See also this question.

Community
  • 1
  • 1
Nivas
  • 18,126
  • 4
  • 62
  • 76
0

You can manipulate with data values in jquery6 just before display it like this

Andrey Gubarev
  • 771
  • 4
  • 6