IBM Support

Computing week number (XDATE.WEEK) with Sunday as start of week

Troubleshooting


Problem

I want a command that will look at the value of an SPSS date variable and count the number of calendar weeks, or parts thereof, from the beginning of the same year. This is like the xdate.week function, but that function always treats the start of the week as the day on which Jan. 1 fell in that year. So the XDATE.WEEK result for Jan 4. would always be 1. If Jan. 4 fell on a Sunday, then I want my command to set the week number for Jan. 4 to 2, showing that it is the second calendar week in that year. In other words, the Sunday on or just before Jan. 1 is the starting point for counting weeks. Suppose that I wanted to treat Monday, rather than Sunday, as the beginning of the calendar week. Would the adjustments described above be possible in that scenario?

[{"Product":{"code":"SSLVMB","label":"IBM SPSS Statistics"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Component":"Not Applicable","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"Not Applicable","Edition":"","Line of Business":{"code":"LOB76","label":"Data Platform"}}]

Log InLog in to view more of this document

This document has the abstract of a technical article that is available to authorized users once you have logged on. Please use Log in button above to access the full document. After log in, if you do not have the right authorization for this document, there will be instructions on what to do next.

Historical Number

15395

Document Information

Modified date:
16 April 2020

UID

swg21476103