Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I calculate what next week's date will be? 2

Status
Not open for further replies.

rleiman

Programmer
May 3, 2006
258
US
Hi Everyone,

Can you tell me how to calculate what next week's date will be? For example the date is Thursday 7-Sep-2006 and I would like to claculate it to be Thursday 14-Sep-2006 I would also like to use the same technique for next month or next year etc.

Thanks.

Emad
 
If you define a field NewDate as long, here is a solution

! New Week
NewDate = Date(Month(Today()),Day(Today())+7,Year(Today()))
!End

! New Month
NewDate = Date(Month(Today())+1,Day(Today()),Year(Today()))
!End

! New Year
NewDate = Date(Month(Today()),Day(Today()),Year(Today())+1)
!End

Hope this helps

Serge
 
Hi Serge.

Wow. That was fast!

That code is what I was looking for. Thanks.

Truly,
Emad
 
Hi Emad,


NextWeek = TODAY() + 7
NextMonth = DATE( MONTH(TODAY()) + 1, DAY(TODAY()), YEAR(TODAY())
NextYear = DATE( MONTH(TODAY()), DAY(TODAY()), YEAR(TODAY()+1)

Date % 7 ! % is the MODULUS operator
0 -> Sunday
1 -> Monday
...
6 -> Saturday

Note: CW's DATE command handle values outside of the normal range.
So DATE( 13, 25, 2006) = DATE( 1, 25, 2007)

HTH,
-- Mark
 
Hi Mark,

Thanks for your code as well as the code from Serge.

I will be using your Date % 7 because I need to check wether the date the user enters is on a Thursday. Thanks.

It's all very helpfull.

Truly,
Emad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top