Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Weekday calculation


Message #1 by "Baysaye" <e.saye@c...> on Tue, 6 Mar 2001 21:38:39 +0100
I have a form with two important fields: "Today()"

and Expected Date.

Part I:

The value of the "Expected Date" field have to be "Today()" +2. That means

Expected Date must always be 2 days after Today().

Part II:

The second part is that I have a 5-days weekday (working days). I want

Expected Date to be 4 days later if Today() is Friday. That means I work

till Friday and my next Expected Date from Friday has to be Monday, i.e. 4

days later (Saturday, Sunday, + the extra 2 days - see part I above).



Any idea? Thks in advanced....









Message #2 by "Pardee, Roy E" <roy.e.pardee@l...> on Tue, 06 Mar 2001 14:31:14 -0800
Look into the DateAdd() and Day() functions in the online help--that should

get you going.



Cheers,



-Roy



-----Original Message-----

From: Baysaye [mailto:e.saye@c...]

Sent: Tuesday, March 06, 2001 12:39 PM

To: Access

Subject: [access] Weekday calculation





I have a form with two important fields: "Today()"

and Expected Date.

Part I:

The value of the "Expected Date" field have to be "Today()" +2. That means

Expected Date must always be 2 days after Today().

Part II:

The second part is that I have a 5-days weekday (working days). I want

Expected Date to be 4 days later if Today() is Friday. That means I work

till Friday and my next Expected Date from Friday has to be Monday, i.e. 4

days later (Saturday, Sunday, + the extra 2 days - see part I above).



Any idea? Thks in advanced....





Message #3 by "John Ruff" <papparuff@c...> on Tue, 6 Mar 2001 16:47:20 -0800
In the following example, I call your Today() field; txtToday and your

ExpectedDate; txtExpectedDate for clarify.  Add the following code to your

form...



Private Sub AddDate()



    If WeekDay(txtToday) = 6 Then

        txtExpectedDate = DateAdd("d", 3, txtToday)

    Else

        txtExpectedDate = DateAdd("d", 2, txtToday)

    End If



End Sub



Private Sub Form_Load()



    AddDate



End Sub



Private Sub txtToday_AfterUpdate()



    AddDate



End Sub



Set the Default Value of the txtToday field to Date()

When the form opens, the txtToday field will automatically be filled with

today's date.



The "AddDate" in the Private Sub Form_Load and the Private Sub

txtToday_AfterUpdate() calls the Private Sub AddDate routine.  If the

txtToday date is Friday (Weekday(txtToday)=6) then make the txtExpectedDate

field = next Monday's date.  If the txtToday field is anything other than

Monday, make txtExpectedDate two days from what txtTodays is.





John Ruff - The Eternal Optimist :)

 -----Original Message-----

From: 	Baysaye [mailto:e.saye@c...]

Sent:	Tuesday, March 06, 2001 12:39 PM

To:	Access

Subject:	[access] Weekday calculation



I have a form with two important fields: "Today()"

and Expected Date.

Part I:

The value of the "Expected Date" field have to be "Today()" +2. That means

Expected Date must always be 2 days after Today().

Part II:

The second part is that I have a 5-days weekday (working days). I want

Expected Date to be 4 days later if Today() is Friday. That means I work

till Friday and my next Expected Date from Friday has to be Monday, i.e. 4

days later (Saturday, Sunday, + the extra 2 days - see part I above).



Any idea? Thks in advanced....







Message #4 by philip.moh@a... on Wed, 7 Mar 2001 08:52:51 +0800
the easier way is to use the calendar object to do this...



> -----Original Message-----

> From:	Baysaye [SMTP:e.saye@c...]

> Sent:	Wednesday, March 07, 2001 4:39 AM

> To:	Access

> Subject:	[access] Weekday calculation

> 

> I have a form with two important fields: "Today()"

> and Expected Date.

> Part I:

> The value of the "Expected Date" field have to be "Today()" +2. That means

> Expected Date must always be 2 days after Today().

> Part II:

> The second part is that I have a 5-days weekday (working days). I want

> Expected Date to be 4 days later if Today() is Friday. That means I work

> till Friday and my next Expected Date from Friday has to be Monday, i.e. 4

> days later (Saturday, Sunday, + the extra 2 days - see part I above).

> 

> Any idea? Thks in advanced....

> 

> 

> 

> 
Message #5 by "Baysaye" <e.saye@c...> on Wed, 7 Mar 2001 22:50:30 +0100
Thanks all for input. ya all GREAT. Thanks again...





"Baysaye" <e.saye@c...> wrote in message news:45404@a...

>

> I have a form with two important fields: "Today()"

> and Expected Date.

> Part I:

> The value of the "Expected Date" field have to be "Today()" +2. That means

> Expected Date must always be 2 days after Today().

> Part II:

> The second part is that I have a 5-days weekday (working days). I want

> Expected Date to be 4 days later if Today() is Friday. That means I work

> till Friday and my next Expected Date from Friday has to be Monday, i.e. 4

> days later (Saturday, Sunday, + the extra 2 days - see part I above).

>

> Any idea? Thks in advanced....

>

>

>

>

>

>






  Return to Index