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 3958430
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:36:32+00:00 2026-05-20T02:36:32+00:00

To extract a week from a date in MySQL, there are several options, but

  • 0

To extract a week from a date in MySQL, there are several options, but I was asking if there is a difference between WEEK(date, 0) and DATE_FORMAT(date, '%U') from an implementation point of view.

I mean, the 2 functions return the same results, but in the background, is it the same implementation? Does one call the other? Is there a deprecated one?

I’ve searched the MySQL date and time functions documentation without finding any answer. Thanks for your enlightenment!

Note : depending on what you want on the output, you should have to use one or the other with different parameters (0 to 52 weeks or 0 to 53? starts on Sunday or Monday? First week with at least 3 days?), but I’m asking about this particular case.

  • 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-20T02:36:32+00:00Added an answer on May 20, 2026 at 2:36 am

    As commentors said, week() seems to be a shortcut for the general date_format() function.
    Plus as @nos mentioned, date_format() returns a string (due to its general behavior I guess), although week() returns an integer.

    I wanted to investigate to verify that theory, and looked into the source code.
    The two functions are implemented in the item_timefunc.cc file.

    • date_format calls make_date_time, implemented line 633
    • week leads to line 1232

    And guess what? They both lead to the calc_week function in sql_time.cc
    So, week(date) is not really a shortcut for date_format(date, '%v'), but they both call the same function, after computing the parameters from the input.

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

Sidebar

Related Questions

I'd like to extract a date from any string entered. But not specific to
I need to extract and decode barcodes and text from images. Is there any
I would like to extract static text from between HTML tags: <p> text here
I have a query like: SELECT EXTRACT(WEEK FROM j.updated_at) as week, count(j.id) FROM jobs
I need to extract the last date only from a string that looks like
Extract from CLR via C# on Boxing / Unboxing value types ... On Boxing:
Extract the number after #/ from my string: abcdefg#/123 .
I extract the audio from a bunch of flv files as an MP3. This
I would like to extract the date a jpg file was created. Java has
How do you extract an RT_RCDATA section from a Win32 executable (preferably in C#)?

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.