Alter Type STRING to DATE

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

Alter Type STRING to DATE

drfg2008
We have a date variable as the following:

2012-09-04

Format:
STRING 10.

Is it possible to use <ALTER TYPE> command to change it into a date format?

Something like: ALTER TYPE v1 (A10 = date8).

(this command just produces missings)

Dr. Frank Gaeth

Reply | Threaded
Open this post in threaded view
|

Re: Alter Type STRING to DATE

Ruben Geert van den Berg
Dear Frank,

In alter type, you should specify the data format that would have been applicable to your datestring if it had been a date. It seems the right format here is "sdate10". Only after the alter type command has converted your string into a date type should you specify the desired format. Please try:

data list free/somedate(a10).
begin data
2012-09-13
end data.

alter type somedate(a10=sdate10).

formats somedate(edate10).

Best,

Ruben

> Date: Wed, 3 Oct 2012 03:04:19 -0700

> From: [hidden email]
> Subject: Alter Type STRING to DATE
> To: [hidden email]
>
> We have a date variable as the following:
>
> 2012-09-04
>
> Format:
> STRING 10.
>
> Is it possible to use <ALTER TYPE> command to change it into a date format?
>
> Something like: ALTER TYPE v1 (A10 = date8).
>
> (this command just produces missings)
>
>
>
>
>
> -----
> Dr. Frank Gaeth
> FU-Berlin
>
> --
> View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Alter-Type-STRING-to-DATE-tp5715442.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> 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: Alter Type STRING to DATE

drfg2008
Thanks

sdate


couldn't find that.

F.


Dr. Frank Gaeth

Reply | Threaded
Open this post in threaded view
|

Re: Alter Type STRING to DATE

David Marso
Administrator

FWIW
sdate means sortable date ;-)

drfg2008 wrote
Thanks

sdate


couldn't find that.

F.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Alter Type STRING to DATE

John F Hall
In reply to this post by drfg2008
Have a look at pp 63 ff in the manual.  In the GUI click on:

Help >> Command Syntax Reference

Scroll down to Date and Time formats, and off you go!


John F Hall (Mr)

Email:    [hidden email]
Website: www.surveyresearch.weebly.com





-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
drfg2008
Sent: 03 October 2012 12:54
To: [hidden email]
Subject: Re: Alter Type STRING to DATE

Thanks

sdate


couldn't find that.

F.






-----
Dr. Frank Gaeth
FU-Berlin

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Alter-Type-STRING-to-DATE-tp57
15442p5715445.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

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

Re: Alter Type STRING to DATE

Jon K Peck
In reply to this post by drfg2008
Table 2-2 in the CSR lists all 24 of the date formats.  ALTER TYPE will do the conversion via sdate as Ruben said.  You can also do it with COMPUTE and the NUMBER function one variable at a time.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        drfg2008 <[hidden email]>
To:        [hidden email]
Date:        10/03/2012 04:58 AM
Subject:        Re: [SPSSX-L] Alter Type STRING to DATE
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Thanks

sdate


couldn't find that.

F.






-----
Dr. Frank Gaeth
FU-Berlin

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Alter-Type-STRING-to-DATE-tp5715442p5715445.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

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