date format in query |
[eluser]Rodrigo Berlinck[/eluser]
hello guys, i always use date_format from SQL for convert date but how make this from querys of ci? exemple: Code: $this->db->where("id",$id"); thanks
[eluser]steelaz[/eluser]
Wrong forum, next time please use this one if you want to ask questions - http://ellislab.com/forums/viewforum/127/ To solve your problem, try: Code: $this->db->select('DATE_FORMAT(date, "%y/%m/%d") AS date');
[eluser]Bart v B[/eluser]
Almost right.. The alias needs to be other then de column name. Otherwise you can get in trouble with things if you want to do more. Code: $this->db->select('DATE_FORMAT(date, "%y/%m/%d") AS date_NL');
[eluser]Rodrigo Berlinck[/eluser]
sorry for posting in the wrong forum. I understood perfectly, thanks for the help
[eluser]Hammoc Matthew[/eluser]
I write code the same above but it error. help me! Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM (`tb_news`) ORDER BY `new_created` DESC LIMIT 8' at line 2 SELECT DATE_FORMAT(new_created, `"%y/%m/%d")` AS new_day FROM (`tb_news`) ORDER BY `new_created` DESC LIMIT 8 Filename: E:\WWW\gamemobile24h\system\database\DB_driver.php Line Number: 330
[eluser]Sagar Ratnaparkhi[/eluser]
As per query you posted, it looks like you added extra quote after date_format syntax.
[eluser]Hammoc Matthew[/eluser]
This is my query. Can you help me? $this->db->select('*'); $this->db->select('DATE_FORMAT(new_created,"%d/%m") as "day"') but an error happened as the code above
[eluser]Sagar Ratnaparkhi[/eluser]
Try this $this->db->select("DATE_FORMAT(new_created,'%d/%m') as day"); |
Welcome Guest, Not a member yet? Register Sign In |