Assuming your awk has time-related functions mktime() and strftime() (mawk or GNU awk), then the awk script
BEGIN {
OFS = FS = ","
}
{
t = mktime(sprintf("%4d %.2d %.2d 00 00 00",
substr($1,2,4),
substr($1,6,2),
substr($1,8,2)));
$1 = substr($1,1,1) strftime("%Y%m%d", t - 7*24*60*60)
print
}
would break apart the date specification in the first comma-delimited column using multiple calls to substr() and create a Unix timestamp with mktime().
It would then decrease the generated timestamp by exactly seven days (in seconds) and re-format it as a YYYYMMDD date string using strftime(). The generated date string, along with the first character of the first column's data (a D in the example) is then assigned to the first column before the whole modified line is printed.
Testing the above script on some data:
$ cat file
D20200826,S2927,977,1
D20200106,S2927,977,1
$ awk -f script.awk file
D20200819,S2927,977,1
D20191230,S2927,977,1
A slightly shorter variant:
BEGIN { OFS = FS = "," }
{
$1 = substr($1,1,1) strftime("%Y%m%d",
mktime(sprintf("%4d %.2d %.2d 00 00 00",
substr($1,2,4),
substr($1,6,2),
substr($1,8,2))) - 7*24*60*60)
}
1
And, as a "one-liner":
awk -F, '{ $1 = substr($1,1,1) strftime("%Y%m%d",mktime(sprintf("%4d %.2d %.2d 00 00 00",substr($1,2,4),substr($1,6,2),substr($1,8,2)))-7*24*60*60) }; 1' OFS="," file
datecommand.