# daynumberofyear - script and chart function

This function calculates the day number of the year in which a timestamp falls. The calculation is made from the first millisecond of the first day of the year, but the first month can be offset.

Syntax:

DayNumberOfYear(timestamp[,start\_month])

**Return data type:** integer

The function always uses years based on 366 days.

Arguments:

DayNumberOfYear arguments

| Argument | Description |
| --- | --- |
| timestamp | The date to evaluate. |
| start\_month | By<br>specifying a start\_month between<br>2 and 12 (1, if omitted), the beginning of the year may be moved forward<br>to the first day of any month. For example, if you want to work with a fiscal<br>year starting March 1, specify start\_month<br>= 3. |

Examples and results:

These examples use the date format DD/MM/YYYY. The date format is specified in the SET DateFormat statement at the top of your load script. Change the format in the examples to suit your requirements.

Example 1:

`DayNumberOfYear('12/09/2014')`

Returns 256, the day number counted from the first of the year.

Example 2:

`DayNumberOfYear('12/09/2014',3)`

Returns 196, the number of the day, as counted from 1 March.

Example 3:

Add the example script to your document and run it. Then add, at least, the fields listed in the results column to a sheet in your document to see the result.

`ProjectTable:` `LOAD recno() as InvID, * INLINE [` `StartDate` `28/03/2014` `10/12/2014` `5/2/2015` `31/3/2015` `19/5/2015` `15/9/2015` `] ;` `NrDays:` `Load *,` `DayNumberOfYear(StartDate,4) As DayNrYear` `Resident ProjectTable;` `Drop table ProjectTable;`

` `

The resulting table shows the returned values of DayNumberOfYear for each of the records in the table.

Example 3 results

| InvID | StartDate | DayNrYear |
| --- | --- | --- |
| 1 | 28/03/2014 | 363 |
| 2 | 10/12/2014 | 254 |
| 3 | 5/2/2015 | 311 |
| 4 | 31/3/2015 | 366 |
| 5 | 19/5/2015 | 49 |
| 6 | 15/9/2015 | 168 |