I have a problem and I can't figure out the solution. With a previously asked question (SELECT rows with time 30 minutes or less?) I tried to make my COUNT(*) function work but I can't make it work. Anybody an idea?
SELECT COUNT(*) FROM g_ad_view WHERE ad_view_time >= DATEADD(mi, -30, GETDATE())
And this is the error I get back:
SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION 18RVS15.DATEADD does not exist
DATE_ADD() function in MySQL is used to add a specified time or date interval to a specified date and then return the date. Specified date to be modified. Here the value is the date or time interval to add. This value can be both positive and negative.
Use the DATE_ADD() function if you want to increase a given date in a MySQL database. In our example, we increased each start date by two days. This function takes two arguments.
INSERT INTO yourTableName VALUES(DATE_ADD(now(),interval n day)); In the above syntax, you can use curdate() instead of now(). The curdate() will store only date while now() will store both date and time.
The DATEADD() function adds a time/date interval to a date and then returns the date.
The MySQL syntax is:
WHERE ad_view_time >= now() - interval 30 minute
DateAdd is missspelled: It must be DATE_ADD (with underscore). See the documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With