Date format

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

Date format

Muir Houston-2
Hi Listers

Trying to use a date format - the excel file I am importing has two
fields which contain dates in a ddmmyy format - however, there are no
spaces or punctuation between dd mm and yy

Is the best way to insert a '.' or '/' between parts of the string or is
there another way

I tried using the GUI to change to one of the date formats offered, but
succeeded only in wiping out the data - so shut down and open again


Thanks

Muir

=====================
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: Date format

Art Kendall
I assumed that you wanted a date variable,and that inserting the
punctuation was just a step toward that.  If not please reply, it is
also possible to create a string variable that people will read as a
date, but will not be a date variable.
try something like this untested syntax, be sure to double check the
century assigned.
You may want the date variable to be displayed in a format other than
date10.

numeric myday mymonth myyear (f2).
compute myday   = number(substr(olddate,1,2),f2).
compute mymonth = number(substr(olddate,3,2),f2).
compute myyear  = number(substr(olddate,5,2),f2).
numeric newdate (date10).
compute newdate = date.dmy(myday,mymonth,myyear).


Art Kendall
Social Research Consultants

Muir Houston wrote:

> Hi Listers
>
> Trying to use a date format - the excel file I am importing has two
> fields which contain dates in a ddmmyy format - however, there are no
> spaces or punctuation between dd mm and yy
>
> Is the best way to insert a '.' or '/' between parts of the string or is
> there another way
>
> I tried using the GUI to change to one of the date formats offered, but
> succeeded only in wiping out the data - so shut down and open again
>
>
> Thanks
>
> Muir
>
> =====================
> 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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Date format

Muir Houston-2
Hi Art,
your solution worked fine - and you interpreted what I wanted - a date variable
 
thanks
Muir
 
Dr Muir Houston
Lecturer
DACE
Faculty of Education
University of Glasgow
0141-330-4699

________________________________

From: Art Kendall [mailto:[hidden email]]
Sent: Mon 22/09/2008 13:37
To: Muir Houston
Cc: [hidden email]
Subject: Re: Date format



I assumed that you wanted a date variable,and that inserting the
punctuation was just a step toward that.  If not please reply, it is
also possible to create a string variable that people will read as a
date, but will not be a date variable.
try something like this untested syntax, be sure to double check the
century assigned.
You may want the date variable to be displayed in a format other than
date10.

numeric myday mymonth myyear (f2).
compute myday   = number(substr(olddate,1,2),f2).
compute mymonth = number(substr(olddate,3,2),f2).
compute myyear  = number(substr(olddate,5,2),f2).
numeric newdate (date10).
compute newdate = date.dmy(myday,mymonth,myyear).


Art Kendall
Social Research Consultants

Muir Houston wrote:

> Hi Listers
>
> Trying to use a date format - the excel file I am importing has two
> fields which contain dates in a ddmmyy format - however, there are no
> spaces or punctuation between dd mm and yy
>
> Is the best way to insert a '.' or '/' between parts of the string or is
> there another way
>
> I tried using the GUI to change to one of the date formats offered, but
> succeeded only in wiping out the data - so shut down and open again
>
>
> Thanks
>
> Muir
>
> =====================
> 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