—•Today is •—

The following SAS program is an example on how to separate the date and time from a datetime value, then recombine them using with the DHMS function.


	data test;
  	set carlo.test;
    	if '01nov2003:00:00:00'dt<=activitydate<='30nov003:00:00:00'dt;
      	dt=activitydate;
      	date=datepart(dt);
      	time=timepart(dt);
      	hh=hour(time);
      	mm=minute(time);
      	ss=second(time);
      	put date=mmddyy10. /
        	  time=timeampm10.;
          	datetime1=dhms(date,hh,mm,ss);
          	datetime2=dhms(date,0,0,time);
      	put datetime1=datetime22. /
        	  datetime2=datetime22.;
	run;

	date=11/10/2003
	time=12:00 AM
	datetime1=10NOV2003:00:00:00
	datetime2=10NOV2003:00:00:00
				

Print Document

Copyright © 2002-2005 www.nycinformatics®.com All Rights Reserved
Last edited on: May 28, 2006
SAS product or service names are registered trademarks of SAS Institute, Inc. in the USA and other countries.
® indicates USA registration.