简体   繁体   中英

vba: get the week day number from a date?

I would like to get the week day number from a date.

Eg : if it is a Monday returns 1, if it is a Tuesday it returns 2, ... if it is a Sunday it returns 7.

I was wondering if there is a direct function to obtain this, for instance:

DayNumber = Format(Date, <format unknown to me>)

The closest I could get is to use the function:

DayNumber = Format(Date, "dddd")

then loop through a predefined list of possible names, but I still wonder if there is a simpler way?

稍微搜索一下就可以找到WEEKDAY函数

weekday(date,vbMonday)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM