Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Mathematics
General TopicsResearchOperations ResearchStatisticsMathematical LogicNumerical AnalysisUndergraduate MathAlgebra HelpRecreational Math
Math Software
MapleMathematicaMATLABScilabSASSPSS

Math Forum / Math Software / SPSS / October 2008



Tip: Looking for answers? Try searching our database.

Date into string

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Asil - 21 Oct 2008 21:17 GMT
Hello,

Could anyone tell me how would I convert date (adate10) variable into
string (a8) ? I was able to partition the date into 3 variables as
year, month, and day in numeric form but stuck there.

Ex: 9/10/2007 into "20070910"

Thanks in advance,

Asil
Bruce Weaver - 21 Oct 2008 23:48 GMT
> Hello,
>
[quoted text clipped - 7 lines]
>
> Asil

string datestr (a8).
compute #d = xdate.mday(date).
compute #m = xdate.month(date).
compute #y = xdate.year(date).
compute #datenum = #y*10000 + #m*100 + #d.
compute datestr = string(#datenum,f8.0).
exe.

--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."
fred.sutton@lsc.gov.uk - 22 Oct 2008 14:08 GMT
You could use this version, it's a little more elegant than Bruce's,
his is a bit old school, (he's starting to show his age methinks).

string Datestr(A8).
comp Datestr=Replace(String(date,SDATE10),"/","").
exe.

Fred

> > Hello,
>
[quoted text clipped - 20 lines]
> bwea...@lakeheadu.cahttp://sites.google.com/a/lakeheadu.ca/bweaver/
> "When all else fails, RTFM."
Asil - 22 Oct 2008 14:20 GMT
Thanks Fred,

I could not get it to work, no value came out in the new variable. Any
ideas? I am using v13.

Asil

Syntax:
string dob3(A8).
comp dob3=Replace(String(dob,SDATE10),"/""").
exe.

Data
dob
01/28/1975
01/21/1986
11/30/1983

On Oct 22, 9:08 am, fred.sut...@lsc.gov.uk wrote:
> You could use this version, it's a little more elegant than Bruce's,
> his is a bit old school, (he's starting to show his age methinks).
[quoted text clipped - 31 lines]
>
> - Show quoted text -
Bruce Weaver - 22 Oct 2008 14:55 GMT
> Thanks Fred,
>
> I could not get it to work, no value came out in the new variable. Any
> ideas? I am using v13.
>
> Asil

Look for REPLACE in the help file.  I bet it wasn't there yet in v13.
Sometimes it pays to be old-school.  ;-)

--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."
fred.sutton@lsc.gov.uk - 24 Oct 2008 07:59 GMT
That's it Bruce, you're right again, I'm going back to the abacus, you
knew where you were with them!

Fred

> > Thanks Fred,
>
[quoted text clipped - 10 lines]
> bwea...@lakeheadu.cahttp://sites.google.com/a/lakeheadu.ca/bweaver/
> "When all else fails, RTFM."
Asil - 22 Oct 2008 14:14 GMT
Thanks Bruce,

It worked perfectly fine.

Asil

> > Hello,
>
[quoted text clipped - 20 lines]
> bwea...@lakeheadu.cahttp://sites.google.com/a/lakeheadu.ca/bweaver/
> "When all else fails, RTFM."
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.