+ 1
How can I change the date and year format in SQL?
3 odpowiedzi
+ 1
What do you want to do ?
Show a date or save a date in a database ?
Have a look at these links.
https://www.sqlshack.com/sql-convert-date-functions-and-formats/
https://www.geeksforgeeks.org/sql-date-functions/
https://www.mssqltips.com/sqlservertip/2655/format-sql-server-dates-with-format-function/
0
what you are trying to do is probably change a stored datetime value to a format you prefer for your locale.
what you need to realize is you don't have to store a datetime value in your preferred locale format.
you can store it as a Unix timestamp value (seconds since epoch) and then when you pull date values from your database (SELECT query) you can usually use a function like DATE to format the value however you like at that time.
look at DATE function and you will probably see what you want.
this is for sqlite: https://www.sqlite.org/lang_datefunc.html
0
The date or datetime is stored in the database in a uniform manner (doesn't depend on locale).
The way it is displayed to you when you query, is however dependent on the language and location setting of the database or the client program itself.
You can format dates to your liking also by converting to character with a specific format string code, but the way is specific to the db engine.
eg. in Oracle database it is like
TO_CHAR(your_date, 'YYYY/MM/DD')