How to get live tag last value changed and timestamp using system.tag.querytaghistory

I don’t know how to use system.tag.queryhistory to get tha live tag last changed value and timestamp and write that value to a text filed. Can any one help me how to use that query to write to text filed