Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3722386
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:53:07+00:00 2026-05-19T05:53:07+00:00

(see my answer below for solution – thanks for the feedback) It’s probably something

  • 0

(see my answer below for solution – thanks for the feedback)

It’s probably something really obvious but I can’t see what’s wrong with my sql:

mysql> CREATE FUNCTION start_of_minute(
->     curdate DATE)
->   RETURNS DATE
->   DETERMINISTIC
->   SQL SECURITY INVOKER
->   BEGIN
->     DECLARE sofm DATE;
->     SET sofm = SUBDATE (
->         curdate,
->         INTERVAL SECOND(curdate) SECOND
->       );
->   RETURN sofm;
->   END //
ERROR 1064 (42000): 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 ');
RETURN sofm;
END' at line 11

All the more frustrating as the following works:

mysql> CREATE FUNCTION start_of_week(
->     curdate DATE,
-> first_day_of_week INTEGER)
->    RETURNS DATE
->    DETERMINISTIC
->    SQL SECURITY INVOKER
->    BEGIN
->       DECLARE sow DATE;
->       SET sow = SUBDATE(
->         curdate,
->         INTERVAL (WEEKDAY(curdate)+(7-first_day_of_week)%7) DAY
->         );
->       RETURN sow;
->    END //
Query OK, 0 rows affected (0.00 sec)

(NB there may be other ways of truncating the date at various levels – and I’d certainly be interested in hearing about them, I really want to know what’s wrong with my syntax – not a different method for calculating the start of a period).

Yes, second() is a valid function, and SECOND is a valid interval.

TIA

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T05:53:09+00:00Added an answer on May 19, 2026 at 5:53 am

    I had already considered that it was getting upset about the types – however replacing all the ‘date’ types with ‘DATETIME’ types did not resolve the problem – turns out the problem was a space between ‘SUBDATE’ and ‘(‘ – I never knew MySQL was fussy about such things!

    (I’d flag this as an asnwer but SO wants me to wait a couple of days first)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UPDATE: I found a solution. See my Answer below. My Question How can I
Problem solved: Thanks guys, see my answer below. I have a website running in
Just posting the solution I worked out today. See my answer below. If you
*Edit: Please see my answer below for the solution. Is there any danger in
Edit: I have solved this by myself. See my answer below I have set
Update: Solved, with code I got it working, see my answer below for the
I'm pretty new to Spring, so apologies if I don't see the obvious answer
EDIT: See my working code in the answers below. In brief: I have a
ANSWER: If you ever see these lines and are mistified like I was, here's
See title. By lightweight markup I mean something like markdown or wikitext.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.