Sample Header Ad - 728x90

How to return values from psql to bash with custom session settings

1 vote
1 answer
1606 views
I need to set the datestyle to "dd/mm/yyyy" before calling a procedure and getting it's return value back to bash. I tried the following:
read return <<< $(psql \
                  -x \
                  -U postgres \
                  -d MY_DB \
                  --quiet`\
                  -t \
                  -c "SELECT CURRENT_TIMESTAMP")    //just to make sure the date format is correct 
echo ${return} | cut -d'|' -f 2
I'm getting back a normal date format yyyy-mm-dd.
Asked by Majd (121 rep)
Nov 6, 2021, 11:01 PM
Last activity: Apr 8, 2022, 12:19 AM