Trả sunday monday trong google sheet

Trả về một số đại diện cho ngày trong tuần của ngày [theo lịch] đã cho.

Ví dụ mẫu

WEEKDAY[DATE[1969;7;20]]

WEEKDAY[A2]

WEEKDAY[40909]

WEEKDAY[40909;3]

Cú pháp

WEEKDAY[ngày; [loại]]

  • ngày – Ngày [theo lịch] để xác định ngày trong tuần. Phải là một giá trị tham chiếu đến ô có chứa ngày [theo lịch], hàm trả về loại ngày [theo lịch] hoặc số.

  • loại[ TÙY CHỌN – mặc định là 1 ] – Số chỉ báo hệ thống số nào dùng để biểu thị các ngày trong tuần. Theo mặc định, số đếm bắt đầu với Chủ nhật = 1.

    • Nếu loại là 1, thì ngày được tính từ Chủ nhật và giá trị của Chủ Nhật là 1, do đó, giá trị của thứ Bảy là 7.

    • Nếu loại là 2, thì ngày được tính từ thứ Hai và giá trị của thứ Hai là 1, do đó giá trị của Chủ Nhật là 7.

    • Nếu loại là 3, thì ngày được tính từ thứ Hai và giá trị của thứ Hai là 0, do đó giá trị của Chủ Nhật là 6.

Lưu ý

  • Đảm bảo rằng giá trị nhập vào hoặc là một giá trị tham chiếu đến ô có chứa ngày [theo lịch], loại hàm trả về ngày [theo lịch] chẳng hạn như hàm DATE, hàm DATEVALUE hoặc hàm TO_DATE, hoặc là số sê-ri ngày [theo lịch] của loại kết quả được hàm N trả về. Google Trang tính biểu thị ngày [theo lịch] nội bộ dưới dạng số để dễ sử dụng trong tính toán và trong khi phép chuyển đổi này là tự động khi một ngày [theo lịch] ở dạng chuỗi được nhập vào ô, thì hàm này không thực hiện phép chuyển đổi này.

  • Hàm WEEKDAY không tự biến đổi các định dạng số theo cách mà Google Trang tính thực hiện dựa trên việc nhập trực tiếp vào các ô. Do đó, WEEKDAY[10/10/2000] được thể hiện dưới dạng WEEKDAY[0,0005], thương của 10 chia 10 chia 2000.

  • Hàm WEEKDAY trả về ngày trong tuần ở dạng số, không phải dạng chữ [ví dụ: 'M' hoặc 'F'], cũng không phải dạng tên viết tắt [ví dụ: 'T3' hoặc 'T4'] hay dạng tên đầy đủ [ví dụ: 'thứ Tư']. Để nhận được tên của ngày trong tuần, hãy sử dụng hàm TEXT hoặc thay đổi định dạng số trên ô.

Xem thêm

YEAR: Trả về năm chỉ định sẵn bằng một ngày cho sẵn [theo lịch].

TO_DATE: Chuyển đổi một số cho sẵn thành giá trị ngày [theo lịch].

N: Trả về đối số cho sẵn dưới dạng một số.

MONTH: Trả về tháng của năm có ngày [theo lịch] cụ thể, ở định dạng số.

DAY: Trả về ngày của tháng có giá trị ngày nhất định [theo lịch], ở định dạng số.

DATEVALUE: Chuyển đổi chuỗi ngày [theo lịch] đã cho ở định dạng đã biết thành giá trị ngày [theo lịch].

DATE: Chuyển đổi năm, tháng, và ngày thành giá trị ngày [theo lịch].

TEXT: Chuyển đổi một số thành văn bản theo định dạng chỉ định sẵn.

Ví dụ

Trả về số biểu thị cho ngày trong tuần cho giá trị ngày chỉ định sẵn.

Tạo bản sao

Thông tin này có hữu ích không?

Chúng tôi có thể cải thiện trang này bằng cách nào?

There will be instances where we may need to know the day of the week, for a given date. In Google Sheets, the WEEKDAY function can help us with this.

Syntax

  • date – is the input date that the function takes into determining the day of the week. This can be a reference to a cell that holds a date value, or a formula that returns a date or even a number that the Google Sheets can evaluate to a date.
  • type – this is an optional indicator that lets the function know where to begin the week from. Valid values that we can key in for this parameter are 1, 2 and 3.
    • 1 is the value by default. In this case, the week starts on Sunday and ends on Saturday. Therefore, value for Sunday is 1 and Saturday is 7.
    • If we keyed in 2 for this parameter, the week begins on Monday and ends on Sunday. Hence, value for Monday is 1 and Sunday is 7.
    • Similarly, if this parameter is 3, the week begins on Monday and ends on Sunday. But the difference here is that the value for Monday is 0 and Sunday is 6.

How to use WEEKDAY function

I’ll dive into a few examples to provide a better understanding of the function’s working behaviour. Please consider the snapshot below.

You will notice I have illustrated all types of WEEKDAY function types [as shown in column A]. For the purpose of clarity, I indicated against each function type, the starting day, ending day and their corresponding WEEKDAY values in columns B and C.

As per the given input type, and the day the input date evaluates to, the function accordingly returns the output [column D]. The first three example cases are of type 1 and returned the values 7,4 and 6, which correspond to Saturday, Wednesday, and Friday respectively. The next three cases are of type 2 and returned 6, 3 and 5 for the same dates used in the first three cases. Similarly, the final three cases returned are of type 3. Therefore the results are 5, 2 and 4.

WEEKDAY out of range

What if you enter a different type other than that mentioned above? You can be sure to see an error, of course! I’ll try that here.

You can further extend the use of the WEEKDAY function by using the value it returns as the input to another function. For instance, here’s an example of an employee who needs to wear a different colored uniform each day according to the data shown below.

WEEKDAY and VLOOKUP

The WEEKDAY function is used to determine the day of the week for a date, and then the VLOOKUP function is used to match the weekday with the corresponding uniform color. This is achieved with the formula =Vlookup[Weekday[Today[],2],A2:C8,3,False].

WEEKDAY and CHOOSE

What if you want to generate the day of the week for a list of dates? There is a simple way to do that using the WEEKDAY function in combination with the CHOOSE function. In the example below, this is done by typing =Choose[Weekday[A6,1],”Sunday”,”Monday”,”Tuesday”,”Wednesday”,”Thursday”,”Friday”,”Saturday”].

Here, the WEEKDAY function is the input to the CHOOSE function, which takes the number generated by the WEEKDAY function and uses it to select the appropriate weekday choice.

Make sure to get yourself known with the TODAY function as well in the following blog posts: How to use the TODAY function in Google Sheets and How to use the WEEKNUM formula in Google Sheets.

Editor’s note: This is a revised version of a previous post that has been updated for accuracy and comprehensiveness.

Chủ Đề