[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Kim

10/10/2005 3:05:00 PM

how to convert the date from yyyy/mm/dd to yyyy/ww
w=week
4 Answers

marcin

10/10/2005 5:23:00 PM

0

according to iso 8601 the first week of the year is the week which contains
first thursday of january

<dateOfFirstMondayOfTheFirstWeek> := <dateOfFirstThursday> - 3;
<daysSinceFirstDayOfTheFirstWeek> := <today> -
<dateOfFirstMondayOfTheFirstWeek>;
<todayweek> := <daysSinceFirstDayOfTheFirstWeek> / 7 + 1;

Kim

10/10/2005 7:42:00 PM

0



"marcin" wrote:

> according to iso 8601 the first week of the year is the week which contains
> first thursday of january
>
> <dateOfFirstMondayOfTheFirstWeek> := <dateOfFirstThursday> - 3;
> <daysSinceFirstDayOfTheFirstWeek> := <today> -
> <dateOfFirstMondayOfTheFirstWeek>;
> <todayweek> := <daysSinceFirstDayOfTheFirstWeek> / 7 + 1;
>

my code show below
H +=
Utility::addSpaces(strRem(date2str(stable.CREATEDDATE,321,2,4,2,4,4),"/"),8);

the format is yyyy/mm/dd...please helpe me to convert to yyyy/ww

Palle Agermark [MSFT]

10/11/2005 8:39:00 AM

0

Hi,

Please note that according to local standards, there are different ways of
determining the first week of the year:
Starts on Jaurary 1st.
First 4-day week
First full week

Have a look at \Classes\Global\firstWeekOfYear and
\Classes\Global\weekOfYear. The regional settings of the Windows client are
used to determine which model to use.

Best regards,


--
This posting is provided "AS IS" with no warranties, and confers no rights.


"marcin" wrote:

> according to iso 8601 the first week of the year is the week which contains
> first thursday of january
>
> <dateOfFirstMondayOfTheFirstWeek> := <dateOfFirstThursday> - 3;
> <daysSinceFirstDayOfTheFirstWeek> := <today> -
> <dateOfFirstMondayOfTheFirstWeek>;
> <todayweek> := <daysSinceFirstDayOfTheFirstWeek> / 7 + 1;
>

marcin

10/13/2005 1:21:00 PM

0

i use the following method

static int weekOfYear(date _curDate)
{
int weekJan1st;
int dayJan1st;
int week;

int dayOfWeek = firstDayOfWeek();
int numDays;
int firstMonday, dayMonday;

weekJan1st = wkofyr(dateStartYr(_curDate));
dayJan1st = dayofwk(dateStartYr(_curDate));
numDays = date2num(_curDate) - date2num(dateStartYr(_curDate));
firstMonday = 0; dayMonday = dayJan1st - 1;

switch(firstWeekOfYear()) // firstWeekOfYr = 2 is the Axapta wkofyr()
way of doing it.
{
case 0: // Week containing 1/1 is the first week of that year.
while(dayMonday!=dayOfWeek)
{
firstMonday--;
dayMonday--;
if(dayMonday<0)
dayMonday = 6;
}
week = 1+(numDays-firstMonday)/7;
break;

case 1: // First full week following 1/1 is the first week of that
year.
while(dayMonday!=dayOfWeek)
{
firstMonday++;
dayMonday++;
if(dayMonday>6)
dayMonday=0;
}
week = 1+(numDays-firstMonday)/7;
break;

case 2: // First week containing at least four days is the first
week of that year.
week = wkofyr(_curDate);
break;

}

return week;
}

example:

static void Job(Args _args)
{
print Global::weekOfYear(today());
pause;
}


"kim" wrote:


> my code show below
> H +=
> Utility::addSpaces(strRem(date2str(stable.CREATEDDATE,321,2,4,2,4,4),"/"),8);
>
> the format is yyyy/mm/dd...please helpe me to convert to yyyy/ww