It's not so much about time but about intent. If your intent is to move there permanently, it would be when you arrive in the state for the purposes of living there (i.e. not from a while before that when you went to check a place out or for an interview). I believe that most (if not all) states expect you to get a Driver's License from that state within 30-days of moving there.
Something like a Driver's License or State ID would be proof of your residency. These things vary greatly from state to state, so you'd have to research particular states. Or find someone who's done that already.
A bit of searching, specifically for Texas, brought me to this forum thread:
If you / he wish to establish residency here -- here being Texas -- get a Texas Driver's License and Voter Registration here. Government issued ID with a Texas address is pretty much bulletproof defense against being found to be a resident of elsewhere.
Your battle, if there is one, will not be with Texas, but with your present home of record state and/or local government if there are income taxes associated with having been a resident there during the tax year.
Which brings up the other question: You would need to make sure that California does not have some provision that would cause you issues. (This isn't so much a case of income from a company in the state as it about capital gains, but it is still prudent to check.)