Ang: String to date....

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Ang: String to date....

Henrik Dal
Dear Nina. The syntax below is from the Date and time wizard in SPSS. Eurodate is the original string variable and Date is the resulting date variable. I didn´t find the date format dd/mm/yyyy, but yyyy/mm/dd was available.
 

* Date and Time Wizard: date.
COMPUTE date=date.dmy(number(substr(ltrim(eurodate),1,2),f2.0),
    number(substr(ltrim(eurodate),3,2),f2.0), number(substr(ltrim(eurodate),5),f4.0)).
VARIABLE LABELS date ''.
VARIABLE LEVEL  date (SCALE).
FORMATS date (SDATE10).
VARIABLE WIDTH  date(10).
EXECUTE.

 

 

 

 

Good luck!


Henrik Dal
===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Ang: String to date....

MLIves

date format dd/mm/yyyy is (ADATE10).

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Henrik Dal
Sent: Tuesday, August 16, 2016 8:39 AM
To: [hidden email]
Subject: [SPSSX-L] Ang: String to date....

 

Dear Nina. The syntax below is from the Date and time wizard in SPSS. Eurodate is the original string variable and Date is the resulting date variable. I didn´t find the date format dd/mm/yyyy, but yyyy/mm/dd was available.

 


* Date and Time Wizard: date.
COMPUTE date=date.dmy(number(substr(ltrim(eurodate),1,2),f2.0),
    number(substr(ltrim(eurodate),3,2),f2.0), number(substr(ltrim(eurodate),5),f4.0)).
VARIABLE LABELS date ''.
VARIABLE LEVEL  date (SCALE).
FORMATS date (SDATE10).
VARIABLE WIDTH  date(10).
EXECUTE.

 

 

 

 

Good luck!

 

Henrik Dal

===================== 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




This correspondence contains proprietary information some or all of which may be legally privileged; it is for the intended recipient only. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this correspondence and completely dispose of the correspondence immediately. Please notify the sender if you have received this email in error. NOTE: Messages to or from the State of Connecticut domain may be subject to the Freedom of Information statutes and regulations.

===================== 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