Investors & landlords

I moved from another state into California. Regarding the allocation of gains (or losses), does the date of sale override the % of time in the state? (It gives me both options, can I pick and choose which one to use, or do I need to go by the date, if a sale date is provided on the 1099-B?) Thank you!