1. Главная
  2. Документы
  3. Функции
  4. Работа с датами
  5. Примеры вычислений с датами

Примеры вычислений с датами

Вычиление дат начала и окончания каждой недели текущего года

за начало недели принимается - суббота

источник:

CreateTable (x string) | AddRow(-) | ComputeFunction ( start_year, DateTime.Today.BeginYear(), end_year, DateTime.Today.EndYear() ) |
ComputeFunction ( days_year, (end_year - start_year).Days) | Value (days_year);
CreateTable (x string) | AddRow(-) | ComputeFunction ( start_year, DateTime.Today.BeginYear() ) | Value (start_year);
CreateTable (x string) | AddRow(-) | AddColumn (start_day, number, 1) | AddColumn (days_year, number, $result_1) | AddColumn (start_year, datetime, $result_2) |
CloneRow (days_year) | CumSum (start_day) | DeleteColumn (days_year) |
ComputeFunction ( start_date, start_year.AddDays (start_day) ) |
ComputeFunction ( day_of_week, start_date.DayOfWeek ) |
ComputeFunction ( end_day, start_day +6 ) |
ComputeFunction ( end_date, start_year.AddDays (start_day).AddDays(6) ) |
ComputeFunction ( week_n, start_day / 7) |
Having (day_of_week = 6) |
DeleteColumn (days_yea, start_year, day_of_week)

результат:

#xstart_daystart_dateend_dayend_dateweek_n
1-72022-01-08T00:00:00132022-01-14T00:00:001
2-142022-01-15T00:00:00202022-01-21T00:00:002
3-212022-01-22T00:00:00272022-01-28T00:00:003
4-282022-01-29T00:00:00342022-02-04T00:00:004
5-352022-02-05T00:00:00412022-02-11T00:00:005
6-422022-02-12T00:00:00482022-02-18T00:00:006
7-492022-02-19T00:00:00552022-02-25T00:00:007
8-562022-02-26T00:00:00622022-03-04T00:00:008
9-632022-03-05T00:00:00692022-03-11T00:00:009
10-702022-03-12T00:00:00762022-03-18T00:00:0010
11-772022-03-19T00:00:00832022-03-25T00:00:0011
12-842022-03-26T00:00:00902022-04-01T00:00:0012
13-912022-04-02T00:00:00972022-04-08T00:00:0013
14-982022-04-09T00:00:001042022-04-15T00:00:0014
15-1052022-04-16T00:00:001112022-04-22T00:00:0015
16-1122022-04-23T00:00:001182022-04-29T00:00:0016
17-1192022-04-30T00:00:001252022-05-06T00:00:0017
18-1262022-05-07T00:00:001322022-05-13T00:00:0018
19-1332022-05-14T00:00:001392022-05-20T00:00:0019
20-1402022-05-21T00:00:001462022-05-27T00:00:0020
21-1472022-05-28T00:00:001532022-06-03T00:00:0021
22-1542022-06-04T00:00:001602022-06-10T00:00:0022
23-1612022-06-11T00:00:001672022-06-17T00:00:0023
24-1682022-06-18T00:00:001742022-06-24T00:00:0024
25-1752022-06-25T00:00:001812022-07-01T00:00:0025
26-1822022-07-02T00:00:001882022-07-08T00:00:0026
27-1892022-07-09T00:00:001952022-07-15T00:00:0027
28-1962022-07-16T00:00:002022022-07-22T00:00:0028
29-2032022-07-23T00:00:002092022-07-29T00:00:0029
30-2102022-07-30T00:00:002162022-08-05T00:00:0030
31-2172022-08-06T00:00:002232022-08-12T00:00:0031
32-2242022-08-13T00:00:002302022-08-19T00:00:0032
33-2312022-08-20T00:00:002372022-08-26T00:00:0033
34-2382022-08-27T00:00:002442022-09-02T00:00:0034
35-2452022-09-03T00:00:002512022-09-09T00:00:0035
36-2522022-09-10T00:00:002582022-09-16T00:00:0036
37-2592022-09-17T00:00:002652022-09-23T00:00:0037
38-2662022-09-24T00:00:002722022-09-30T00:00:0038
39-2732022-10-01T00:00:002792022-10-07T00:00:0039
40-2802022-10-08T00:00:002862022-10-14T00:00:0040
41-2872022-10-15T00:00:002932022-10-21T00:00:0041
42-2942022-10-22T00:00:003002022-10-28T00:00:0042
43-3012022-10-29T00:00:003072022-11-04T00:00:0043
44-3082022-11-05T00:00:003142022-11-11T00:00:0044
45-3152022-11-12T00:00:003212022-11-18T00:00:0045
46-3222022-11-19T00:00:003282022-11-25T00:00:0046
47-3292022-11-26T00:00:003352022-12-02T00:00:0047
48-3362022-12-03T00:00:003422022-12-09T00:00:0048
49-3432022-12-10T00:00:003492022-12-16T00:00:0049
50-3502022-12-17T00:00:003562022-12-23T00:00:0050
51-3572022-12-24T00:00:003632022-12-30T00:00:0051
52-3642022-12-31T00:00:003702023-01-06T00:00:0052