If the function that changes myvar's value fires an event, you could retrieve the event log from web3 to get the data.
event MyEvent(uint indexed dateModified, uint prevValue, uint newValue);
function changeValue(uint newValue){
uint prevValue = myvar;
myVar = newValue;
MyEvent(now, prevValue, newValue);
}
(Indexing dateModified will let you filter by date for example)
Each time the function is called, the
Then in web3 you would watch (get new events as they happen) or get them (get all past events).
From web3 docs:
var MyContract = web3.eth.contract(abi);
var myContractInstance = MyContract.at('0x78e97bcc5b5dd9ed228fed7a4887c0d7287344a9');
// watch for an event with {some: 'args'}
var myEvent = myContractInstance.MyEvent({some: 'args'}, {fromBlock: 0, toBlock: 'latest'});
myEvent.watch(function(error, result){
...
});
// would get all past logs again.
var myResults = myEvent.get(function(error, logs){ ... });
...
// would stop and uninstall the filter
myEvent.stopWatching();
One more thing: Event logs can only be accessed from outside Solidity, so if you wanted to get your variable's previous values from inside solidity you would need to code your own logic that stores the previous values in an array, probably.