Convert DATE to STRING

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

Convert DATE to STRING

Carlos Renato-2
Dear friends of this list

      Do you know any syntax that convert a date variable, for example
a variable in EDATE10 format 10.10.2002 to a string "10.10.2002"?

Thanks for all responses.

Carlos Renato
Statistician
Reply | Threaded
Open this post in threaded view
|

AW: Convert DATE to STRING

la volta statistics
Hi Carlos,
Try the following syntax:

DATA LIST LIST /myDate(EDATE10).
BEGIN DATA
09.09.2002
10.09.2002
11.09.2002
09.11.2002
END DATA.

STRING strdate(A10).
COMPUTE strdate = STRING(NUMBER(CONCAT(String(XDATE.YEAR(myDate), F4.0),
".",
                                          STRING(XDATE.MONTH(MyDate), f2.0),".",
                                          STRING(XDATE.MDAY(MyDate),F2.0)),SDATE), EDATE10) .
Exec.


Christian

-----Ursprüngliche Nachricht-----
Von: SPSSX(r) Discussion [mailto:[hidden email]]Im Auftrag von
Carlos Renato
Gesendet: Montag, 6. November 2006 14:37
An: [hidden email]
Betreff: Convert DATE to STRING


Dear friends of this list

      Do you know any syntax that convert a date variable, for example
a variable in EDATE10 format 10.10.2002 to a string "10.10.2002"?

Thanks for all responses.

Carlos Renato
Statistician
Reply | Threaded
Open this post in threaded view
|

Re: AW: Convert DATE to STRING

Oliver, Richard
There is a much simpler solution:

string strdate(a10).
compute strdate=string(mydate, edate10).

That's all you need.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of la volta statistics
Sent: Monday, November 06, 2006 9:16 AM
To: [hidden email]
Subject: AW: Convert DATE to STRING

Hi Carlos,
Try the following syntax:

DATA LIST LIST /myDate(EDATE10).
BEGIN DATA
09.09.2002
10.09.2002
11.09.2002
09.11.2002
END DATA.

STRING strdate(A10).
COMPUTE strdate = STRING(NUMBER(CONCAT(String(XDATE.YEAR(myDate), F4.0), ".",
                                          STRING(XDATE.MONTH(MyDate), f2.0),".",
                                          STRING(XDATE.MDAY(MyDate),F2.0)),SDATE), EDATE10) .
Exec.


Christian

-----Ursprüngliche Nachricht-----
Von: SPSSX(r) Discussion [mailto:[hidden email]]Im Auftrag von Carlos Renato
Gesendet: Montag, 6. November 2006 14:37
An: [hidden email]
Betreff: Convert DATE to STRING


Dear friends of this list

      Do you know any syntax that convert a date variable, for example a variable in EDATE10 format 10.10.2002 to a string "10.10.2002"?

Thanks for all responses.

Carlos Renato
Statistician
Reply | Threaded
Open this post in threaded view
|

Re: Convert DATE to STRING

Carlos Renato-2
In reply to this post by la volta statistics
Very much thanks...this syntax solves my doubt.

Carlos Renato


2006/11/6, la volta statistics <[hidden email]>:

>
> Hi Carlos,
> Try the following syntax:
>
> DATA LIST LIST /myDate(EDATE10).
> BEGIN DATA
> 09.09.2002
> 10.09.2002
> 11.09.2002
> 09.11.2002
> END DATA.
>
> STRING strdate(A10).
> COMPUTE strdate = STRING(NUMBER(CONCAT(String(XDATE.YEAR(myDate), F4.0),
> ".",
>                                          STRING(XDATE.MONTH(MyDate), f2.0
> ),".",
>                                          STRING(XDATE.MDAY(MyDate),F2.0)),SDATE),
> EDATE10) .
> Exec.
>
>
> Christian
>
> -----Ursprüngliche Nachricht-----
> Von: SPSSX(r) Discussion [mailto:[hidden email]]Im Auftrag von
> Carlos Renato
> Gesendet: Montag, 6. November 2006 14:37
> An: [hidden email]
> Betreff: Convert DATE to STRING
>
>
> Dear friends of this list
>
>      Do you know any syntax that convert a date variable, for example
> a variable in EDATE10 format 10.10.2002 to a string "10.10.2002"?
>
> Thanks for all responses.
>
> Carlos Renato
> Statistician
>
>
Reply | Threaded
Open this post in threaded view
|

Re: AW: Convert DATE to STRING

Carlos Renato-2
In reply to this post by Oliver, Richard
Good, very good. This second syntax is simple and solves my problem too.

Thanks for all responses.

Carlos Renato


2006/11/6, Oliver, Richard <[hidden email]>:

>
> There is a much simpler solution:
>
> string strdate(a10).
> compute strdate=string(mydate, edate10).
>
> That's all you need.
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> la volta statistics
> Sent: Monday, November 06, 2006 9:16 AM
> To: [hidden email]
> Subject: AW: Convert DATE to STRING
>
> Hi Carlos,
> Try the following syntax:
>
> DATA LIST LIST /myDate(EDATE10).
> BEGIN DATA
> 09.09.2002
> 10.09.2002
> 11.09.2002
> 09.11.2002
> END DATA.
>
> STRING strdate(A10).
> COMPUTE strdate = STRING(NUMBER(CONCAT(String(XDATE.YEAR(myDate), F4.0),
> ".",
>                                          STRING(XDATE.MONTH(MyDate), f2.0
> ),".",
>                                          STRING(XDATE.MDAY(MyDate),F2.0)),SDATE),
> EDATE10) .
> Exec.
>
>
> Christian
>
> -----Ursprüngliche Nachricht-----
> Von: SPSSX(r) Discussion [mailto:[hidden email]]Im Auftrag von
> Carlos Renato
> Gesendet: Montag, 6. November 2006 14:37
> An: [hidden email]
> Betreff: Convert DATE to STRING
>
>
> Dear friends of this list
>
>      Do you know any syntax that convert a date variable, for example a
> variable in EDATE10 format 10.10.2002 to a string "10.10.2002"?
>
> Thanks for all responses.
>
> Carlos Renato
> Statistician
>