ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   get week day of a date (https://www.excelbanter.com/excel-programming/358666-get-week-day-date.html)

ashishprem[_12_]

get week day of a date
 

Hi All,
I want some help regarding date function in macro. I want to know th
week day number of the date. For eg on 30/12/2005 its Friday. I want th
week day number. For eg Sunday -1 ,Monday -2 .... Friday -6 Saturday
7.
For 30/12/2005, the result will be 6. Is there any function to get th
week day number?

Regards
Ashis

--
ashishpre
-----------------------------------------------------------------------
ashishprem's Profile: http://www.excelforum.com/member.php...fo&userid=3148
View this thread: http://www.excelforum.com/showthread.php?threadid=53216


Gary Keramidas

get week day of a date
 
this should do it, i used a1 for the date and b1 for the result

Sub test()
Range("b1").Value = Weekday(Range("a1"))
End Sub

just for reference, if you wanted monday for the first day of the week, then you
would use this and the value would be 5

Range("b1").Value = Weekday(Range("a1"), vbMonday)
--


Gary


"ashishprem" wrote in
message ...

Hi All,
I want some help regarding date function in macro. I want to know the
week day number of the date. For eg on 30/12/2005 its Friday. I want the
week day number. For eg Sunday -1 ,Monday -2 .... Friday -6 Saturday -
7.
For 30/12/2005, the result will be 6. Is there any function to get the
week day number?

Regards
Ashish


--
ashishprem
------------------------------------------------------------------------
ashishprem's Profile:
http://www.excelforum.com/member.php...o&userid=31485
View this thread: http://www.excelforum.com/showthread...hreadid=532162




Nigel

get week day of a date
 
Excel worksheet formula WEEKDAY yields the value you require e.g.
=WEEKDAY(A1,1)

The same can be used in VBA code e.g.

MyDOW = Weekday(Range("A1"),1)


--
Cheers
Nigel



"ashishprem" wrote
in message ...

Hi All,
I want some help regarding date function in macro. I want to know the
week day number of the date. For eg on 30/12/2005 its Friday. I want the
week day number. For eg Sunday -1 ,Monday -2 .... Friday -6 Saturday -
7.
For 30/12/2005, the result will be 6. Is there any function to get the
week day number?

Regards
Ashish


--
ashishprem
------------------------------------------------------------------------
ashishprem's Profile:
http://www.excelforum.com/member.php...o&userid=31485
View this thread: http://www.excelforum.com/showthread...hreadid=532162





All times are GMT +1. The time now is 06:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com