Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert regular Date to Week Ending or Week Beginning Dates Sam H Excel Discussion (Misc queries) 5 April 3rd 23 04:39 PM
Display "this week" column headers w/date & day of week? Ivan Wiegand Excel Worksheet Functions 9 September 12th 07 05:18 PM
Date Function formula that will return the date of a specific week Greg Excel Worksheet Functions 4 June 12th 06 05:07 PM
Finding the Monday date based on a different date in same week dandiehl Excel Worksheet Functions 4 April 11th 06 06:03 PM
I need week number in excell from a date, first week must be mini. jPeich Excel Discussion (Misc queries) 4 January 5th 05 01:21 AM


All times are GMT +1. The time now is 12:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"