I am using PostgreSQL, I am facing an issue in that I am not able to fetch the record’s date range between
actually, in my database, I am saving this type of date in column “2022-12-21 16:12:15”
My PG Query is - "SELECT * FROM table WHERE DATE_FORMAT(date_column,'%YYYY-%MM-%DD') BETWEEN '2022-12-21' AND '2023-03-20'"
ERROR: function date_format(text, unknown) does not exist
LINE 1: ... WHERE DATE_FORMA...
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
go to http://sqlfiddle.com, and click on the hamburger at the right of the header bar so that you can choose PostgreSQL as your database, then build a schema using CREATE TABLE that exactly mirrors your date_column, and then use INSERT statements to populate a few rows, making sure you include a few value both within and outside the range you want, then share the link with us so that we can see why the SQL suggested is not working
but this query is wrong, I expect the query will return 3 rows bcz from 21 to 23 there is 3 records exist in db, it show 1 records only.
overall there is one plus date is required to supply, that is wrong logically.
but why is this function working in phpmyadmin and MySQL, there is no concern about the date range 21-22 there is just input 21-21 it works.
It might be due to DATE_FORMATE() is there an option same as we can do in PostgreSQL?
What is the problem ? actually I was working on phpmyadmin and this database is not able to handle my big database records as usually very slow speed for calculation, fetch and etc.
so I planned to switch to PostgreSQL here this DATE_FORMATE() not working, I am confused in MYSQL I used UNION, and JOINING with two different database tables the same query will run on PostgreSQL OR not…
Even if I like Postgre more then mySQL there is no increase of speed if you use the same queries on postgre instead of mySQL. Postgre is definitely not faster then MySQL if you do not know how to use the advantages
To be honest, you don’t get a better lumberjack by changing your handsaw by a chainsaw….
First step is to learn the basics and the most important is to not store dates and/or times in text or varchar fields.
After you are able to choose the right column types for the data you need, it is a good idea to even know (and respect) as a minimum the first three normalization rules
After that you can start to analyze your queries with the explain command to see what is slow and what can be improved.
I have developed applications with both databases and at the end both are running fine if you know how to store and retrieve the data correctly.