Won't the weekday argument ("w") work well with DateAdd() function?

prabha_friend

Prabhakaran Karuppaih
Local time
Today, 09:56
Joined
Mar 22, 2009
Messages
1,037
Today: 06/08/2015 (Monday)
Expression: Dateadd("w",-1,Date())
Resulting Value: 06/07/2015 (Sunday)
Expected Value: 06/05/2015 (Friday)

How to make this work?
 
currently have given this:

(Weekday(Date())=2) And ([Log_Date] Between DateAdd("d",-3,Date()) And Date()) Or (Weekday(Date())<>2) And ([Log_Date] Between DateAdd("d",-1,Date()) And Date())
 
weekday does not mean 'Monday to Friday' but provides a value for any given day (1-7 for Sunday to Saturday) - I think you probably know this

in the context of dateadd, "w" is the same as "d"

If you want to ignore weekends, you will need a function to do this. There are plenty of examples for this on the forum. or take a look at this link

https://support.microsoft.com/en-us/kb/207795
 
currently have given this:

(Weekday(Date())=2) And ([Log_Date] Between DateAdd("d",-3,Date()) And Date()) Or (Weekday(Date())<>2) And ([Log_Date] Between DateAdd("d",-1,Date()) And Date())
See how a "simple" validation rule is becoming more and more complex prabha ;)

Also, if this was done in code, it would only need to validate one condition using an IF statement, whereas in a validation rule such as yours, it's having to validate all conditions each time.
 

Users who are viewing this thread

Back
Top Bottom