View previous topic :: View next topic |
Author |
Message |
sanjayr321 Beginner
Joined: 25 Sep 2006 Posts: 28 Topics: 15
|
Posted: Sun Aug 22, 2010 10:00 pm Post subject: Convert date fields into character |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12370 Topics: 75 Location: San Jose
|
Posted: Mon Aug 23, 2010 10:17 am Post subject: |
|
|
sanjayr321,
what programming language are we talking about ?
Kolusu |
|
Back to top |
|
|
sanjayr321 Beginner
Joined: 25 Sep 2006 Posts: 28 Topics: 15
|
Posted: Mon Aug 23, 2010 6:15 pm Post subject: |
|
|
Sorry not to mentioned it earlier...it SAS in Enterprise guide 4. |
|
Back to top |
|
|
Dibakar Advanced
Joined: 02 Dec 2002 Posts: 699 Topics: 63 Location: USA
|
Posted: Mon Aug 23, 2010 7:27 pm Post subject: |
|
|
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 |
|
|
sanjayr321 Beginner
Joined: 25 Sep 2006 Posts: 28 Topics: 15
|
Posted: Mon Aug 23, 2010 9:27 pm Post subject: |
|
|
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 |
|
|
Dibakar Advanced
Joined: 02 Dec 2002 Posts: 699 Topics: 63 Location: USA
|
Posted: Tue Aug 24, 2010 12:07 pm Post subject: |
|
|
Thanks for confirming _________________ Regards,
Diba |
|
Back to top |
|
|
|
|