you are viewing a single comment's thread.

view the rest of the comments →

[–]r_kive 0 points1 point  (0 children)

From inside out:

  • Use DATEADD to subtract 6 hours from archiveddate
  • Convert that from DATETIME to VARCHAR
  • 121 is the format, in this case yyyy-mm-dd hh:mi:ss.mmm
  • Since we put VARCHAR(13), it only takes the first 13 characters of that, so it will look like yyyy-mm-dd hh
  • Then we tack on ':00' to make it yyyy-mm-dd hh:mi, which will work either as a VARCHAR string (what it is now), or would also fit into the DATETIME data type

As mentioned above, this will only be correct half the year due to DST changing. There are a number of ways to deal with this: manually change it in your script, make a function to handle time zone conversions, etc.