Problem solve Get help with specific problems with your technologies, process and projects.

Changing the date and time in SQL Server using T-SQL

A quick commmand that changes the date and time in SQL Server, complete with warnings!

Watch out -- This option is extremely dangerous! It will prevent all your scheduled jobs from running. Certainly do not use it yourself, but it may be useful to check that nobody in your organization has already used it. It is equal to sabotage!

USE master 
exec xp_cmdshell 'echo 02/16/2000 | date' 
exec xp_cmdshell 'echo 09:00:00 | time' 

For More Information

  • What do you think about this tip? E-mail us at [email protected] with your feedback.
  • The Best SQL Server Web Links: tips, tutorials, scripts, and more.
  • Have an SQL Server tip to offer your fellow DBA's and developers? The best tips submitted will receive a cool prize--submit your tip today!
  • Ask your technical SQL Server questions--or help out your peers by answering them--in our live discussion forums.
  • Check out our Ask the Experts feature: Our SQL, Database Design, Oracle, SQL Server, DB2, metadata, and data warehousing gurus are waiting to answer your toughest questions.

Dig Deeper on SQL-Transact SQL (T-SQL)