0

I have a data april/2010 to jan/2011 Is there any way to split the data with character to and select the date as The value before "to" as FROM and The Value after "to" as TO how to selet the splited value......... while i am selecting the data as it is as select date from mytbl how to select the date as two values

1
  • Please show full, complete examples of what the fields look like, and the desired results. Otherwise, it's impossible to suggest correct splitting or regex code. Commented Apr 3, 2010 at 10:52

1 Answer 1

1

If you have your data in a string, like this :

$str = 'april/2010 to jan/2011';

You can use the explode function to get the two parts :

list ($from, $to) = explode(' to ', $str);


Then, just to be sure, if we echo them :

echo "From : $from<br />";
echo "To : $to<br />";

We get :

From : april/2010
To : jan/2011
Sign up to request clarification or add additional context in comments.

1 Comment

@pascal Martin Thanks for your effort ....But This is like getting the result and then spliting data i am looking for a method which splits the data in the query itself like < select date as from,date as To

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.