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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find the Day # (2nd Mon of each month)

Status
Not open for further replies.

lareya

Technical User
Jan 30, 2003
49
US
Okay,
Is it possible to check what DayofWeek it is in regards to where it lies in each month? Example 1st monday, 2nd monday, 3rd Thu, 5th Friday of the month?

I have a formula I found that gives the Last Month of the Day. here:
dateserial(year({Post Case.ENTER_PROC_ROOM_DATE}), month({Post Case.ENTER_PROC_ROOM_DATE})+1,01)-1

I also have a formula that gives the Day of the Month here:
If DayOfWeek ({Post Case.ENTER_DEPT_DATE}) = 1 then "SUN"
else if DayOfWeek ({Post Case.ENTER_DEPT_DATE}) = 2 then "MON"
else if DayOfWeek ({Post Case.ENTER_DEPT_DATE}) = 3 then "TUE"
else if DayOfWeek ({Post Case.ENTER_DEPT_DATE}) = 4 then "WED"
else if DayOfWeek ({Post Case.ENTER_DEPT_DATE}) = 5 then "THU"
else if DayOfWeek ({Post Case.ENTER_DEPT_DATE}) = 6 then "FRI "
else if DayOfWeek ({Post Case.ENTER_DEPT_DATE}) = 7 then "SAT"

So how can I find this type of info:
Date Day Day#InMonth
01/04/2005 Tue 1
01/05/2005 Wed 1
01/11/2005 Tue 2
01/12/2005 Wed 2

I thought this formula worked, It starts out working, but doesn't re-set for each month. (I think):

local dateTimeVar InputDate:={Post Case.ENTER_PROC_ROOM_DATE};
local numbervar A;
local numbervar B;
local datevar C;
local numbervar D;

A := Weekday(InputDate);
B := Year(InputDate + ((8 - A) Mod 7) - 3);
C := cdate(B, 1, 1);
D := (Weekday(C) + 1) Mod 7;
(InputDate - C - 3 + D) \ 7 + 1

However, I can't interpet this formula very well, but I think it is close.

January is correct but then the other months are wrong. It yields this:
Date Day Day#InMonth
02/09/2005 Wed 6 *should be 2
02/14/2005 Mon 7 *should be 2
02/25/2005 Fri 8 *should be 4
03/02/2005 Wed 9 *should be 1


Thanks a lot! Please disregard my other posting which I didn't explain/understand the situation too well.

Lareya

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Crystal 8.5; ORSOS/One Call Hospital Scheduling System v9.3; SQL database; Huge Newbie to Crystal! Operating Room RN Analyst
 
Lareya,

Try this, it appears to work, but only you can confirm that

Code:
Day({Post Case.ENTER_PROC_ROOM_DATE}) \ 7
+
If (Day({Post Case.ENTER_PROC_ROOM_DATE}) Mod 7) > 0 Then
    1

Peter.
 
This indeed work :)
Thank you very much!

Lareya

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Crystal 8.5; ORSOS/One Call Hospital Scheduling System v9.3; SQL database; Huge Newbie to Crystal! Operating Room RN Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top