Hy... a situation, i need to know what week of the month a date is, for example if it is the 1st week of the month, if the second week of the month, if it is the third week, fourth or fifth week of the month for a specific date, in addition of this I need to know for the same date which is the week of the year.. for example if it is the 20th week of the 21st month so on, looking at the OCONV documentation for the mask date, I found only the options for the day of the week and for quarter of the year. Does anyone have any simpler suggestions to find out this information? for now the only solution I found was to loop for the entire year and calculate this, but this is impractical, as I will have to store a "calendar" in the database
i'm using d3 linux 10.2
Page 1 / 1
Hy... a situation, i need to know what week of the month a date is, for example if it is the 1st week of the month, if the second week of the month, if it is the third week, fourth or fifth week of the month for a specific date, in addition of this I need to know for the same date which is the week of the year.. for example if it is the 20th week of the 21st month so on, looking at the OCONV documentation for the mask date, I found only the options for the day of the week and for quarter of the year. Does anyone have any simpler suggestions to find out this information? for now the only solution I found was to loop for the entire year and calculate this, but this is impractical, as I will have to store a "calendar" in the database
i'm using d3 linux 10.2
i'm using d3 linux 10.2
I share the algo we use from years.
manu
SUBROUTINE WeekNo(WEEK, DATE)
year = OCONV(DATE, 'D4Y')
gosub calc
WEEK = int((DATE - day1) / 7) + 1
if DATE < day1 then
year -= 1
gosub calc
WEEK = int((DATE - day1) / 7) + 1
end else
if WEEK = 53 then
year += 1
gosub calc
if day1 >= dd0101 then WEEK = 1
end
end
return
*---------------------------------------
calc:
date0101 = ICONV('01.01.' : year, 'D4.') ;* date of first january
dd0101 = OCONV(date0101, 'DW') ;* day of week of first january
if dd0101 < 4 then shift = 1 else shift = 8
day1 = date0101 - dd0101 + shift
return
Hy... a situation, i need to know what week of the month a date is, for example if it is the 1st week of the month, if the second week of the month, if it is the third week, fourth or fifth week of the month for a specific date, in addition of this I need to know for the same date which is the week of the year.. for example if it is the 20th week of the 21st month so on, looking at the OCONV documentation for the mask date, I found only the options for the day of the week and for quarter of the year. Does anyone have any simpler suggestions to find out this information? for now the only solution I found was to loop for the entire year and calculate this, but this is impractical, as I will have to store a "calendar" in the database
i'm using d3 linux 10.2
i'm using d3 linux 10.2
I suppose WeekofMonth can be :
int( oconv(date,'DD') / 7 ) + 1
Hy... a situation, i need to know what week of the month a date is, for example if it is the 1st week of the month, if the second week of the month, if it is the third week, fourth or fifth week of the month for a specific date, in addition of this I need to know for the same date which is the week of the year.. for example if it is the 20th week of the 21st month so on, looking at the OCONV documentation for the mask date, I found only the options for the day of the week and for quarter of the year. Does anyone have any simpler suggestions to find out this information? for now the only solution I found was to loop for the entire year and calculate this, but this is impractical, as I will have to store a "calendar" in the database
i'm using d3 linux 10.2
i'm using d3 linux 10.2
Thanks Manu
It works perfectly everything, it was just everything that I needed, and with a good code I imagine that I was going to have to invoke ghosts to get to this result hahah
thanks again for your quick response...
Sign up
Already have an account? Login
Welcome to the Rocket Forum!
Please log in or register:
Employee Login | Registration Member Login | RegistrationEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.