The replacement ${MYDATE%" "} will remove a single space from the end of the string. To match space followed my more text, we need to add a *, and to remove the longest matching substring, we need %% rather than %. We don't need to quote the space in the substitution, so the simplest equivalent is ${MYDATE%% *}.
Demo:
$ MYDATE='2017-08-21 20:35:28 +0200'
$ echo ${MYDATE%% *}
2017-08-21
From a cursory reading of the git show documentation, it appears that you can get the output in the format you want, without having to do any extra work subsequently:
git show -s --format=%cd --date=short HEAD
# Or, using a standard `strftime` format string:
git show -s --format=%cd --date=format:%F HEAD
These both give an ISO-8601 format date; if you want it without the - separators, then you'll need a format string of %Y%m%d:
git show -s --format=%cd --date=format:%Y%m%d HEAD
exportit (which you shouldn't do unnecessarily), or if there already existed an environment variable by the same name in your program's environment.MyVaris safe, as ismyvar, whereasMYVARis not).