Discussione:
utilià x calcolo: numero settimana nell'anno, giorno della settimana
(troppo vecchio per rispondere)
a***@deejaymail.it
2012-01-04 15:31:23 UTC
Permalink
con il nuovo anno, la nostra procedura di calcolo del numero della settimana nell'anno è impazzita.

Avete mica un qualcosa di già fatto che funzioni ?
Il dato mi serve all' 'italiana'
1=lun 2=mar .. 7=domenica
la prima settimana è fino al primo sabato dell'anno e cosi via.

se fosse bastata la convenzione ISO avrei risolto con sql.

Vi chiedo una cosa già fatta in quanto stiamo sbagliando ll'attribuzione del codice lotto di produzione, quindi volevo evitare di perdere del tempo a rifare e testare una cosa da zero.
grazie
Fabio Terrazzin
2012-01-04 17:44:25 UTC
Permalink
Post by a***@deejaymail.it
con il nuovo anno, la nostra procedura di calcolo del numero della settimana nell'anno è impazzita.
Avete mica un qualcosa di già fatto che funzioni ?
Il dato mi serve all' 'italiana'
1=lun 2=mar .. 7=domenica
la prima settimana è fino al primo sabato dell'anno e cosi via.
se fosse bastata la convenzione ISO avrei risolto con sql.
Vi chiedo una cosa già fatta in quanto stiamo sbagliando ll'attribuzione del codice lotto di produzione, quindi volevo evitare di perdere del tempo a rifare e testare una cosa da zero.
grazie
cosa intendi all'italiana? per me la convenzione ISO è all'italiana
infatti corrisponde con la settimana che vediamo nei calendari
CRPence
2012-01-04 19:10:16 UTC
Permalink
Post by a***@deejaymail.it
con il nuovo anno, la nostra procedura di calcolo del numero della
settimana nell'anno è impazzita.
Avete mica un qualcosa di già fatto che funzioni ?
Il dato mi serve all' 'italiana'
1=lun 2=mar .. 7=domenica
la prima settimana è fino al primo sabato dell'anno e cosi via.
se fosse bastata la convenzione ISO avrei risolto con sql.
Vi chiedo una cosa già fatta in quanto stiamo sbagliando
ll'attribuzione del codice lotto di produzione, quindi volevo
evitare di perdere del tempo a rifare e testare una cosa da zero.
The following SQL scalar functions:

_i DAYNAME i_ "Returns a mixed case character string containing the
name of the day (for example, Friday) for the day portion of the
argument. ... Note: National language considerations: The name of the
day that is returned is based on the language used for messages in the
job. This name of the day is retrieved from message CPX9034 in message
file QCPFMSG in library *LIBL."

_i WEEK_ISO i_ "The WEEK_ISO function returns an integer between 1
and 53 that represents the week of the year. The week starts with
Monday. Week 1 is the first week of the year to contain a Thursday,
which is equivalent to the first week containing January 4. Thus, it is
possible to have up to 3 days at the beginning of the year appear as the
last week of the previous year or to have up to 3 days at the end of a
year appear as the first week of the next year."

_i DAYOFWEEK_ISO i_ "The DAYOFWEEK_ISO function returns an integer
between 1 and 7 that represents the day of the week, where 1 is Monday
and 7 is Sunday."

ILE RPG Examples "RPGLE - Day of week/Week of year" with Procedure:
DayOfWeek [although that may require adjustment by adding one] and
Procedure: WeekOfYear" [among others]:
http://www.code400.com/viewsamples.php?lang_id=1

There are also the ILE Common Execution Environment APIs, with an
example for day-of-week; knowing of these may enable finding others:
_i Examples: Using ILE Common Execution Environment data APIs i_
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/topic/apis/apiexusdata.htm
"...
... callb(d) 'CEEDAYS'
... callb(d) 'CEEDYWK'
... callb(d) 'CEEDATE'
...
"

Regards, Chuck
CRPence
2012-01-04 19:13:59 UTC
Permalink
Post by a***@deejaymail.it
con il nuovo anno, la nostra procedura di calcolo del numero della
settimana nell'anno è impazzita.
Avete mica un qualcosa di già fatto che funzioni ?
Il dato mi serve all' 'italiana'
1=lun 2=mar .. 7=domenica
la prima settimana è fino al primo sabato dell'anno e cosi via.
se fosse bastata la convenzione ISO avrei risolto con sql.
Vi chiedo una cosa già fatta in quanto stiamo sbagliando
ll'attribuzione del codice lotto di produzione, quindi volevo
evitare di perdere del tempo a rifare e testare una cosa da zero.
The following SQL scalar functions:

_i DAYNAME i_ "Returns a mixed case character string containing the
name of the day (for example, Friday) for the day portion of the
argument. ... Note: National language considerations: The name of the
day that is returned is based on the language used for messages in the
job. This name of the day is retrieved from message CPX9034 in message
file QCPFMSG in library *LIBL."

_i WEEK_ISO i_ "The WEEK_ISO function returns an integer between 1
and 53 that represents the week of the year. The week starts with
Monday. Week 1 is the first week of the year to contain a Thursday,
which is equivalent to the first week containing January 4. Thus, it is
possible to have up to 3 days at the beginning of the year appear as the
last week of the previous year or to have up to 3 days at the end of a
year appear as the first week of the next year."

_i DAYOFWEEK_ISO i_ "The DAYOFWEEK_ISO function returns an integer
between 1 and 7 that represents the day of the week, where 1 is Monday
and 7 is Sunday."

ILE RPG Examples "RPGLE - Day of week/Week of year" with Procedure:
DayOfWeek [although that may require adjustment by adding one] and
Procedure: WeekOfYear" [among others]:
http://www.code400.com/viewsamples.php?lang_id=1

There are also the ILE Common Execution Environment APIs, with an
example for day-of-week; knowing of these may enable finding others:
_i Examples: Using ILE Common Execution Environment data APIs i_
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/topic/apis/apiexusdata.htm
"...
... callb(d) 'CEEDAYS'
... callb(d) 'CEEDYWK'
... callb(d) 'CEEDATE'
...
"

Regards, Chuck
Jax
2012-01-04 20:12:44 UTC
Permalink
Post by a***@deejaymail.it
con il nuovo anno, la nostra procedura di calcolo del numero della settimana nell'anno è impazzita.
Avete mica un qualcosa di già fatto che funzioni ?
Il dato mi serve all' 'italiana'
1=lun 2=mar .. 7=domenica
la prima settimana è fino al primo sabato dell'anno e cosi via.
se fosse bastata la convenzione ISO avrei risolto con sql.
Vi chiedo una cosa già fatta in quanto stiamo sbagliando ll'attribuzione del codice lotto di produzione, quindi volevo evitare di perdere del tempo a rifare e testare una cosa da zero.
grazie
In /free:

//*--------------------------------------------------------------*
//* Reperisce il giorno della settimana
//*--------------------------------------------------------------*
begsr Sbr_Giorno;
exec sql set :$giorno = dayofweek_iso(now());
endsr;

Ovviamente puoi anche utilizzare una variabile precedentemente
dichiarata e valorizzata con una data a tua scelta

D $data s d DatFmt(*ISO)
.....
exec sql set :$giorno = dayofweek_iso(:$data);
--
Jax
Danilo Cussini
2012-01-05 08:04:30 UTC
Permalink
Post by a***@deejaymail.it
la prima settimana è fino al primo sabato dell'anno e cosi via.
Funzione SQL WEEK

The WEEK function returns an integer between 1 and 54 that represents the week of the year. The week starts with Sunday, and January 1 is always in the first week.
a***@deejaymail.it
2012-01-05 18:28:28 UTC
Permalink
allitaliana significa NON ISO

nel frattempo ho risolto con questo accrocco, che ripeto è un accrocco ma sembra funzionare:
* DETERMINA GIORNO DELLA SATTIMANA DEL PRIMO DELL'ANNO
C MOVELAA INIZIO 10
C MOVE '-01-01' INIZIO
C Z-ADD0 GSETT§ 10
C/EXEC SQL
C+ SET :GSETT§ = DAYOFWEEK(:INIZIO)
C/END-EXEC
* DETERMINA INFORMAZIONI DELLA DATA RICEVUTA
C Z-ADD0 GSETT 10
C Z-ADD0 GANNO 30
C Z-ADD0 SANNO 20
C/EXEC SQL
C+ SET :GSETT = DAYOFWEEK(:DATISO)
C/END-EXEC
C SUB 1 GSETT 1=DOM 7=SAB
C SELEC
C GSETT WHEQ *ZERO DOMENICA
C Z-ADD7 GSETT
C ENDSL
C/EXEC SQL
C+ SET :GANNO = DAYOFYEAR(:DATISO)
C/END-EXEC
C/EXEC SQL
C+ SET :SANNO = WEEK(:DATISO)
C/END-EXEC
* SE È IL 1° DELL'ANNO DI DOMENICA
C SELEC
C GSETT§ WHEQ 1 1°DELL'ANNO DOM
C SANNO ANDEQ1 PRIMA SETTIMANA
C GSETT ANDEQ7 DOMENICA
C GSETT§ WHEQ 1 1°DELL'ANNO DOM
C GSETT ANDNE7 NO DOMENICA
C ADD 1 SANNO
C GSETT§ WHNE 1 1°DELL'ANNO DOM
C GSETT ANDEQ7 DOMENICA
C SUB 1 SANNO
C ENDSL
*
C MOVE GSETT DAYOFW
C MOVE GANNO DAYOFY
C MOVE SANNO WEEKOY

grazie a tutti
e Buona Befana
Obelix-it
2012-01-10 08:04:30 UTC
Permalink
Post by a***@deejaymail.it
allitaliana significa NON ISO
Ch enon si capisce cosa significhi. ISO indica solo che la prima
settimana dell'anno e' quella che inclue il primo giovedi' dell'anno.

Tu cosa vuoi?? la prima settimana *completa* ??
a***@deejaymail.it
2012-01-16 08:17:36 UTC
Permalink
io voglio che la prima settimana sia quella fino alla prima domenica dell'anno

così come ho fatto funziona, per ora va bene così, grazie obelix
Continua a leggere su narkive:
Loading...