0

I have a table tableA with a timestamp column as shown below

T_SYSTEM_TIMESTAMP
--------------------------
2021-08-05 17:42:05.386000
2021-08-25 11:17:31.776000
2021-08-25 11:19:12.612000

How can I manually changed all the timestamp values to say, 2021-01-01?

In SQL developer I can simply just do the following command for timestamps

update tableA 
set t_system_timestamp = t_system_timestamp - 30;

Since for SQL Server timestamp is not an int I can't do this. Any help would be appreciated.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
code-monkey
  • 236
  • 1
  • 2
  • 11
  • 3
    From the tool tip *"This question does not show any research effort; it is unclear or not useful." This means that at least 2 people agree with that tooltip. Downvotes aren't toxic; never have been, never will be· – Thom A Aug 25 '21 at 16:01
  • Does this answer your question? [How to add minutes to the time part of datetime](https://stackoverflow.com/questions/33760529/how-to-add-minutes-to-the-time-part-of-datetime/33760542) – Thom A Aug 25 '21 at 16:02
  • 1
    Hi Larnu, I don't understand how I can show my research efforts in a question? Because believe me I did some research (I even added the sql developer command which I found but could not find the mssql equivalent). Forgive me for not being good with mssql as I've only just started learning it. – code-monkey Aug 26 '21 at 08:54

1 Answers1

1

In SQL Server, you can use dateadd():

update tableA
    set t_system_timestamp = dateadd(day, -30, t_system_timestamp);
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786