Medtun
8th December 2015, 16:44
Hi,

Is there a function that displays the number of the week of a date ?
For example, Week(08/12/2015) should give 50(week n° 50).
i woud like to display it in a report.

Thank you.

Best regards.

mark_h
8th December 2015, 17:20
Look at num.to.week - I believe it does that for you.

bdittmar
8th December 2015, 19:03
Hi,

Is there a function that displays the number of the week of a date.
For example, Week(08/12/2015) should give 50(week n° 50).
i woud like to display it in a report.

Thank you.

Best regards.

Hello,

in LN there's sprintf$
function string sprintf$ (string format [, void ...])

%D( format ) Use for dates.

This option enables you to define your own date format by using the following subformats of the ‘%D’ format:

%m month in year 1 - 12
%w week in year week 0 in previous year week 53 in current year
%W week in year week 53 in previous year
%d day in month 1 - 31
%e day in week 1 - 7
%j day in year 1 - 365
%y year without century 01 - 99
%Y year with century 1 - 9999
%h name of month (‘Jan’ - ‘Dec’)

(abbreviated)

%H name of month (‘January’ - ‘December’)
%a name of day (‘Sun’ - ‘Sat’)

(abbreviated)

%A name of day (‘Sunday’ - ‘Saturday’)

You can combine these subformats with other formats. Note that strings returned by name of month and day formats are language dependent.

Regards

benito
8th December 2015, 21:24
if you have a utc date, use utc.to.week().

Medtun
9th December 2015, 10:01
Thank you very much sirs.

Have a nice day.

Medtun
9th December 2015, 12:44
Good morning bdittmar,
Thank you for the help.
Can you please write me just an example with this function. I'm a functionnal and not that good at tools.
Thank you again.

bdittmar
9th December 2015, 20:55
Good morning bdittmar,
Thank you for the help.
Can you please write me just an example with this function. I'm a functionnal and not that good at tools.
Thank you again.

Hello,
for example.

At declaration section:
extern domain tcyrno year
extern domain tcweek week
extern domain tcmnth month

function prepare.date.data(domain tctrns.date whinh431.iadt)
{
year = val(sprintf$("%u(%04Y)",whinh431.iadt))
week = val(sprintf$("%u(%02W)",whinh431.iadt))
month = val(sprintf$("%u(%02m)",whinh431.iadt))
}

This function prepares the year, week and month fom the utc-date field of table whinh431.

If actual date is needed: year = val(sprintf$("%u(%04Y)", utc.num()))

Regards

Medtun
10th December 2015, 10:45
Thank you very much Bdittmar.
Very clear example.

Have a nice day.