MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Convert date fields into character

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
sanjayr321
Beginner


Joined: 25 Sep 2006
Posts: 28
Topics: 15

PostPosted: Sun Aug 22, 2010 10:00 pm    Post subject: Convert date fields into character Reply with quote

I need to pass the datetime with length of 29 character to a file. Tried with the below code in enterprise guide.

data temp1;
now=datetime();
format now datetime29.12;
x=put(now,29.);
run;

I got the expected results in 'now' variable as 19AUG10:11:22:32.993000030518 but in the variable X i got as 1598186755 (with blanks at the end)
which i need to pass into the other file.

As required, I need to pass the datetime with character of 29 as the format in variable now but when I tried to convert using PUT fxn, it change into different format as in variable x.

Can you please suggest some idea to convert the 'now' date field into character of 29 without changing the format.

Thanks
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Mon Aug 23, 2010 10:17 am    Post subject: Reply with quote

sanjayr321,

what programming language are we talking about ?

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sanjayr321
Beginner


Joined: 25 Sep 2006
Posts: 28
Topics: 15

PostPosted: Mon Aug 23, 2010 6:15 pm    Post subject: Reply with quote

Sorry not to mentioned it earlier...it SAS in Enterprise guide 4.
Back to top
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 699
Topics: 63
Location: USA

PostPosted: Mon Aug 23, 2010 7:27 pm    Post subject: Reply with quote

My guess is '1598186755' is the value of now, '19AUG10:11:22:32.993000030518' is the formmated data, relevant for display only. So your put statement is probably incorrect because actual value of now is not 29 characters.

What do you want to do with x?
_________________
Regards,
Diba
Back to top
View user's profile Send private message Send e-mail
sanjayr321
Beginner


Joined: 25 Sep 2006
Posts: 28
Topics: 15

PostPosted: Mon Aug 23, 2010 9:27 pm    Post subject: Reply with quote

Hi Dibakar,

Thanks, your correct. I have fixed using the below code.

data temp1;
now=datetime();
x=put(now,datetime29.12);
format now datetime29.12;
run;
Back to top
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 699
Topics: 63
Location: USA

PostPosted: Tue Aug 24, 2010 12:07 pm    Post subject: Reply with quote

Thanks for confirming
_________________
Regards,
Diba
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group