I have a unique problem (at least for me) that I have solved in one way but would like an easier way if possible :)
I often have to test our Windows app with dates in the past. Our app queries a SQL server which uses GETDATE.
I have setup a VM with our app and SQL server on it. I can change the system date backward or forward as needed after doing the below through powershell:
- stopping windows time service
- if running on HyperV, stop the vmictimesync service
- setting the new date
- restart time services
- restarting the sql server (just in case) and our app
It seems to work very well - both our app and the SQL server can't tell the difference.
If I need to reset the date back to current I simply restart the windows time service. Easy.
However, it's a bit of effort to set that up at moments notice and was wondering if there is a way to fool the SQL server or an individual database into thinking it's a different date as needed?
So with the individual db perhaps I can set some properties such that it would shift GETDATE calls back to a certain time period.
All a stretch I know but if anyone has any other ideas I'm all ears.
Unfortunately our devs can't change the app to make this all easier.