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 個月前檢視次數 37 次
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 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南