I have a data set with dates in the following format (and defined as date fields):
01-JUN-2005 00:00:00 I want to change it to a format I can use to select it using greater than or equal to some [date]. Thanks. Sydelle Raffe, Alameda County Social Services Agency Information Services Division e:mail: [hidden email] phone: 510-271-9174 fax: 510-271-9107 If you have a request for information, please submit an ODM request form at: https://alamedasocialservices.org/staff/support_services/statistics_and_reports/odm/index.cfm |
I always found this a real pain,
Untested Solution below: Firstly use the you must extract the date portion of your variable COMPUTE dat_p = XDATE.DATE(your date variable). VAR LAB dat_p "Date portion". VAR LEVEL dat_p (SCALE). FORMATS dat_p (EDATE10). EXECUTE. And then as a select statement you must explicitly define it as a date ie, (this will delete all files not selected) Use all. Select if dat_p >= date.DMYR(01,06,2006). Exe. HtH Mike -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Raffe, Sydelle, SSA Sent: 01 November 2006 22:45 To: [hidden email] Subject: converting a date variable I have a data set with dates in the following format (and defined as date fields): 01-JUN-2005 00:00:00 I want to change it to a format I can use to select it using greater than or equal to some [date]. Thanks. Sydelle Raffe, Alameda County Social Services Agency Information Services Division e:mail: [hidden email] phone: 510-271-9174 fax: 510-271-9107 If you have a request for information, please submit an ODM request form at: https://alamedasocialservices.org/staff/support_services/statistics_and_ reports/odm/index.cfm ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
In reply to this post by Raffe, Sydelle, SSA
The date time values you show are FORMATS. The actual date value is a
number representing the number of seconds after midnight Oct 14, 1582. (If you don't specify a time, then midnight is implied.) You can use the DATE.DMY(a,b,c) syntax directly on your variable (formatted with the time displayed) without extracting the date portion. SELECT IF your_date GE MATE.DMY(22,12,2005). Will work. Note: This code will permanently delete cases from the working file. Be sure this is what you want. Otherwise, use: COMPUTE date_filt = your_date GE DATE.DMY(22,12,2005). FILTER BY date_filt. This will exclude cases from procedures without deleting cases from the working file. cheers --jim -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Michael Pearmain Sent: Thursday, November 02, 2006 9:24 AM To: [hidden email] Subject: Re: converting a date variable I always found this a real pain, Untested Solution below: Firstly use the you must extract the date portion of your variable COMPUTE dat_p = XDATE.DATE(your date variable). VAR LAB dat_p "Date portion". VAR LEVEL dat_p (SCALE). FORMATS dat_p (EDATE10). EXECUTE. And then as a select statement you must explicitly define it as a date ie, (this will delete all files not selected) Use all. Select if dat_p >= date.DMYR(01,06,2006). Exe. HtH Mike -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Raffe, Sydelle, SSA Sent: 01 November 2006 22:45 To: [hidden email] Subject: converting a date variable I have a data set with dates in the following format (and defined as date fields): 01-JUN-2005 00:00:00 I want to change it to a format I can use to select it using greater than or equal to some [date]. Thanks. Sydelle Raffe, Alameda County Social Services Agency Information Services Division e:mail: [hidden email] phone: 510-271-9174 fax: 510-271-9107 If you have a request for information, please submit an ODM request form at: https://alamedasocialservices.org/staff/support_services/statistics_and_ reports/odm/index.cfm ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
In reply to this post by Raffe, Sydelle, SSA
Thaks for the responses -- problem solved.
Sydelle Raffe, Alameda County Social Services Agency Information Services Division e:mail: [hidden email] phone: 510-271-9174 fax: 510-271-9107 If you have a request for information, please submit an ODM request form at: https://alamedasocialservices.org/staff/support_services/statistics_and_reports/odm/index.cfm |
Free forum by Nabble | Edit this page |