|
It's fairly common for data to come in with dates represented as
unpunctuated strings, or as numbers whose decimal representation is such a string: '20080211' or '02112008' for today, 11-FEB-2008. Just recently, a couple of posters have asked how to convert these to SPSS dates; answers have been posted. I wouldn't recommend these representations; but since they occur, it would be useful to have SPSS date formats for them: Format Description Min w General Examples type form 28-OCT-1990 11-FEB-2008 ------------------------------------------------------------- YMDx Unpunctuated 6 yymmdd 901028 080211 YrMnthDay 8 yyyymmdd 19901028 20080211 ------------------------------------------------------------- MDYx Unpunctuated 6 mmddyy 102890 021108 MnthDayYear 8 mmddyyyy 10281990 02112008 ------------------------------------------------------------- ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
I would like to see a lot of additional date/time formats available in SPSS: there is an infinite variety of ways in which dates are represented, including many national variations. But that way lies madness. There will always be another format.
As an alternative, a pattern language for describing dates gives a lot more flexibility. And we have a pattern language available in one of the Python supplementary modules available on Developer Central (www.spss.com/devcentral): extendedTransforms.py in the function strtodatetime. Here, from the docstring, are the pattern symbols. You can compose a description from these such as "%y%m%d" to describe the pattern in a string and create an SPSS date value. The function datetimetostr can be used to go the reverse direction. %a Locale's abbreviated weekday name. %A Locale's full weekday name. %b Locale's abbreviated month name. %B Locale's full month name. %c Locale's appropriate date and time representation. %d Day of the month as a decimal number [01,31]. %H Hour (24-hour clock) as a decimal number [00,23]. %I Hour (12-hour clock) as a decimal number [01,12]. %j Day of the year as a decimal number [001,366]. %m Month as a decimal number [01,12]. %M Minute as a decimal number [00,59]. %p Locale's equivalent of either AM or PM. (1) %S Second as a decimal number [00,61]. (2) %U Week number of the year (Sunday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday are considered to be in week 0. (3) %w Weekday as a decimal number [0(Sunday),6]. %W Week number of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Monday are considered to be in week 0. (3) %x Locale's appropriate date representation. %X Locale's appropriate time representation. %y Year without century as a decimal number [00,99]. %Y Year with century as a decimal number. %Z Time zone name (no characters if no time zone exists). %% A literal "%" character. (1)When used with the strptime() function, the %p directive only affects the output hour field if the %I directive is used to parse the hour. (2)The range really is 0 to 61; this accounts for leap seconds and the (very rare) double leap seconds. (3)When used with the strptime() function, %U and %W are only used in calculations when the day of the week and the year are specified. HTH, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Richard Ristow Sent: Sunday, February 10, 2008 11:48 PM To: [hidden email] Subject: [SPSSX-L] Suggestion: Date formats without punctuation It's fairly common for data to come in with dates represented as unpunctuated strings, or as numbers whose decimal representation is such a string: '20080211' or '02112008' for today, 11-FEB-2008. Just recently, a couple of posters have asked how to convert these to SPSS dates; answers have been posted. I wouldn't recommend these representations; but since they occur, it would be useful to have SPSS date formats for them: Format Description Min w General Examples type form 28-OCT-1990 11-FEB-2008 ------------------------------------------------------------- YMDx Unpunctuated 6 yymmdd 901028 080211 YrMnthDay 8 yyyymmdd 19901028 20080211 ------------------------------------------------------------- MDYx Unpunctuated 6 mmddyy 102890 021108 MnthDayYear 8 mmddyyyy 10281990 02112008 ------------------------------------------------------------- ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
