Database date format to DMY (AWS LIghtsail)

0

Hello

I am trying to change the date format of my AWS Lightsail Database (Postgresql) to ISO DMY When I connect to pdAdmin with the command SELECET NOW(); the result I get is. YYYY-MM-DD HH:MM:SS The result I need is DD-MM-YYYY HH:MM:SS I have tried configuring it via the following methods, but not success

• From Amazon CloudShell with the command aws lightsail update-relational-database-parameters --relational-database-name mydatabase --parameters "parameterName=DateStyle,parameterValue='ISO, DMY',applyMethod=immediate"

With changes to my parameters (db name etc) • From pgAdmin with the query using SQL commands like ALTER DATABASE my_database SET DateStyle = 'SQL, DMY'; With changes to my parameters (db name etc)

Any recommendations?

질문됨 2달 전42회 조회
1개 답변
0

To change the date format of your AWS Lightsail PostgreSQL database to ISO DMY, you're on the right track with using the AWS CLI command. However, there are a few things to consider:

  1. The command you've used is correct, but make sure you've replaced 'mydatabase' with your actual database name.

  2. The parameter 'DateStyle' is case-sensitive, so ensure it's written exactly as shown.

  3. The apply method 'immediate' is correct for dynamic parameters like DateStyle.

  4. After running the command, you may need to reconnect to your database for the changes to take effect.

If you're still not seeing the desired result, you can try the following steps:

  1. First, verify the current parameter value:

    aws lightsail get-relational-database-parameters --relational-database-name your-database-name

  2. If the parameter isn't set correctly, run the update command again:

    aws lightsail update-relational-database-parameters --relational-database-name your-database-name --parameters "parameterName=DateStyle,parameterValue='ISO, DMY',applyMethod=immediate"

  3. After running the command, wait a few minutes for the changes to propagate.

  4. Reconnect to your database and run SELECT NOW(); again to check the format.

If you're still experiencing issues, it's possible that there might be application-level settings overriding the database configuration. In that case, you may need to adjust your application code to format the date as required.

Remember, changing database parameters can have implications for your applications, so always test thoroughly in a non-production environment first.

Sources
Optimize Lightsail database performance with parameter updates - Amazon Lightsail

profile picture
답변함 2달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠