Avatar of finance_teacher
finance_teacher

asked on 

MS SQL -- GetDate(), without -, subtract 7 days ?

Below works, but updates to YYYY-MM-DD with DD of 3006 instead of taking 7 days away.

How can I change so it
 1. updates to YYYYMMDD without "-" and
 2. subtracts 7 days ?

update subscriptions
set parameters =
    substring(parameters, 1, 67)  +
    (select CONVERT(char(10), GetDate()-7,126)) + --ORIGINALLY substring(parameters, 68,8)   +
    substring(parameters, 76, 73) +
    (select CONVERT(char(10), GetDate(),126)) + --ORIGINALLY substring(parameters, 149,8)  +
    substring(parameters, 157, 999)
where subscriptionID in
   (
      --'E6B59B45-2C51-4A6F-906D-CBA4A48371F0',
      '379BC5A4-7F1D-4295-BD11-756154B83789'
   )
Microsoft SQL ServerMicrosoft SQL Server 2005SQL

Avatar of undefined
Last Comment
Jim Horn
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Thanks for the grade.  Good luck with your project.  -Jim
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo