Office中国论坛/Access中国论坛

标题: 星期几的函数如何实现 [打印本页]

作者: king1950    时间: 2008-11-10 07:27
标题: 星期几的函数如何实现
如下表,给年月日在另一列中配相应的星期几
非常谢谢!
作者: tanhong    时间: 2008-11-10 08:47
你给出的时间不是正确的日期格式.
作者: king1950    时间: 2008-11-10 09:48
版主,您好,从软件中导出来就如此,我用设置单元格式又改不动,请您帮忙改一下,非常谢谢版主!
作者: king1950    时间: 2008-11-10 09:57
版主,您好,从软件中导出来就如此,我用替换改了,重新传上,望告知星期的方法,非常谢谢版主!
作者: 方漠    时间: 2008-11-10 15:31
FYI.

WEEKDAY

See Also

Returns the day of the week corresponding to a date. The day is given as an integer, ranging from 1 (Sunday) to 7 (Saturday), by default.

Syntax

WEEKDAY(serial_number,return_type)

Serial_number    is a sequential number that represents the date of the day you are trying to find. Dates should be entered by using the DATE function, or as results of other formulas or functions. For example, use DATE(2008,5,23) for the 23rd day of May, 2008. Problems can occur if dates are entered as text.

Return_type    is a number that determines the type of return value.

Return_type Number returned
1 or omitted Numbers 1 (Sunday) through 7 (Saturday). Behaves like previous versions of Microsoft Excel.
2 Numbers 1 (Monday) through 7 (Sunday).
3 Numbers 0 (Monday) through 6 (Sunday).

Remark
Microsoft Excel stores dates as sequential serial numbers so they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,448 days after January 1, 1900. Microsoft Excel for the Macintosh uses a different date system as its default.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How?

Create a blank workbook or worksheet.
Select the example in the Help topic. Do not select the row or column headers.


Selecting an example from Help

Press CTRL+C.
In the worksheet, select cell A1, and press CTRL+V.
To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and then click Formula Auditing Mode.
   
1
2
A
Data
2/14/2008
Formula Description (Result)
=WEEKDAY(A2) Day of the week, with numbers 1 (Sunday) through 7 (Saturday) (5)
=WEEKDAY(A2,2) Day of the week, with numbers 1 (Monday) through 7 (Sunday) (4)
=WEEKDAY(A2,3) Day of the week, with numbers 0 (Monday) through 6 (Sunday) (3)


Note  2/14/2008 is a Thursday.
作者: tanhong    时间: 2008-11-10 16:54
你的日期格式是文本的,是个麻烦的事情,所以先用DATEVALUE函数转成换,再用WEEKDAY函数

实例:[attach]33087[/attach]
作者: pureshadow    时间: 2008-11-10 17:26
A列所有的数据前面多了个空格。
编辑》替换:
查找为:空格
替换为:什么都不输入
全部替换
然后用weekday(a6,2)下拉就可以了。
其实不用函数,直接在格式》单元格》数字里设置日期里的星期格式也可以。
作者: tanhong    时间: 2008-11-10 18:28
原帖由 pureshadow 于 2008-11-10 17:26 发表
A列所有的数据前面多了个空格。
编辑》替换:
查找为:空格
替换为:什么都不输入
全部替换
然后用weekday(a6,2)下拉就可以了。
其实不用函数,直接在格式》单元格》数字里设置日期里的星期格式也可以。


如果不是文本字符用格式就可以了,但他导下来的数据日期为文本格式.
作者: pureshadow    时间: 2008-11-10 18:34
江版说得没错,所以要先替换掉空格。
作者: king1950    时间: 2008-11-10 22:00
感谢江版!感谢小妖!非常感谢!终于弄明白了。
作者: king1950    时间: 2008-11-11 06:38
还有一点不知什么原因,星期五显示的都是星期日,须替换。
作者: king1950    时间: 2008-11-11 06:39
还有一点不知什么原因,星期五显示的都是星期日,须替换。
作者: li08hua    时间: 2010-4-29 00:48
学习者




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3