[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

MySQL GET_FORMAT() not working as expecte

Posted on 2010-08-13
2
Medium Priority
?
397 Views
Last Modified: 2013-12-13
Hello,

I'm trying to update one datetime field based on other datetime filed that is bigger than 1 day than the other

This is my query:

UPDATE TABLE SET `field`='amyvalue' WHERE datetime_field < GET_FORMAT(UNIX_TIMESTAMP(`other_datetime_field`)-86400, 'ISO')


I'm getting this error:
Error Code : 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 'UNIX_TIMESTAMP(`other_datetime_field`)-86400, 'ISO')' at line 1


How can I use GET_FORMAT() to get it to work properly ?

Thank you
0
Comment
Question by:Ionut A. Tudor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 33427687
what is the data type of datetime_field and other_datetime_field, please?if it's really datetime:http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.htmlhttp://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add
UPDATE TABLE 
  SET `field`='amyvalue' 
WHERE datetime_field < date_sub(`other_datetime_field`, INTERVAL 1 DAY)

Open in new window

0
 
LVL 14

Author Comment

by:Ionut A. Tudor
ID: 33427762
Yes angelll, I needed it for doing the below and it worked. Thanks

UPDATE orders SET `other_datetime_field`=DATE_SUB(`datetime_field`, INTERVAL 2 DAY) WHERE id='1' LIMIT 1

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question