DateDiff Function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have looked everywhere and can not find out how to use the [firstdayofweek] option in the datediff function. I assume you use the number that corresponds with the day of the week, but is it in brackets or quotes? Also, if I only want to use Monday - Friday, how would that look?
 
You can't use DateDiff to eliminate weekends. To do that, take a look in the
Date/Time section of "The Access Web": there are a couple of alternatives
there.

For the record, the FirstDayOfWeek option really only matters for when using
"w" as a parameter, and it's not really intuitive what it does. When you
pick a day, DateDiff will increment the count once for each occurrence of
that day it encounters between the dates. You don't use brackets, but it's a
numeric value between 1 and 7. It's easiest to use the intrinsic constants
vbSunday, vbMonday, ...:

DateDiff("w", dtmDateFrom, dtmDateTo, vbMonday)

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


SKT said:
I have looked everywhere and can not find out how to use the
[firstdayofweek] option in the datediff function. I assume you use the
number that corresponds with the day of the week, but is it in brackets or
quotes? Also, if I only want to use Monday - Friday, how would that look?
 
Thanks, this helps a lot!

Douglas J. Steele said:
You can't use DateDiff to eliminate weekends. To do that, take a look in the
Date/Time section of "The Access Web": there are a couple of alternatives
there.

For the record, the FirstDayOfWeek option really only matters for when using
"w" as a parameter, and it's not really intuitive what it does. When you
pick a day, DateDiff will increment the count once for each occurrence of
that day it encounters between the dates. You don't use brackets, but it's a
numeric value between 1 and 7. It's easiest to use the intrinsic constants
vbSunday, vbMonday, ...:

DateDiff("w", dtmDateFrom, dtmDateTo, vbMonday)

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


SKT said:
I have looked everywhere and can not find out how to use the
[firstdayofweek] option in the datediff function. I assume you use the
number that corresponds with the day of the week, but is it in brackets or
quotes? Also, if I only want to use Monday - Friday, how would that look?
 
Back
Top