2 Replies - 1466 Views - Last Post: 17 October 2012 - 05:26 PM Rate Topic: -----

#1 raelkun00  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 61
  • Joined: 01-October 12

How to get the number of sunday from date

Posted 08 October 2012 - 08:33 AM

This is the code to filter a date in datareport
drFilterReport.Show
    deFilterReport.rsOrders.Filter = "[OrderDate] >= #" & Me.txtFrom.Text & "# And [OrderDate] <= #" & Me.txtTo.Text & "#"



What I need is to count the number of a sunday.
For example: date from October 8,2012 to November 5,2012.There are 4 sundays. What is the code to get it?
Help me please.Thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: How to get the number of sunday from date

#2 leixnt  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 30
  • Joined: 24-July 11

Re: How to get the number of sunday from date

Posted 08 October 2012 - 08:42 PM

use weekday() function & looping to count day from monday-friday

note:
weekday() to check what day is it.
return value (cmiiw)
1 Sunday
2 Monday
3 Tuesday
4 Wednesday
5 Thursday
6 Friday
7 Saturday
Was This Post Helpful? 0
  • +
  • -

#3 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 571
  • View blog
  • Posts: 2,979
  • Joined: 19-May 09

Re: How to get the number of sunday from date

Posted 17 October 2012 - 05:26 PM

Or you can use the Weekdayname function if you don't want to use the number. This is the "brute force" approach. You can do it a lot more efficiently using a formula. Here's an interesting discussion on the subject.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1