Help using Base SAS procedures

datetime fields -1day is causing time to be 00:00.00

Reply
New Contributor
Posts: 3

datetime fields -1day is causing time to be 00:00.00

Hi ,

I would like a date one day away from the value in a datetime field. My new field is getting created with one day subtracted but all of the times are not preserved. They all get set to 00:00:00.

newdt2=intnx('dtday',datetime(),-1) ;

or

newdt1=intnx('dtday',mydatetimefield,-1) ;

What am I doing wrong?

Thanks

Lee

PROC Star
Posts: 7,474

datetime fields -1day is causing time to be 00:00.00

You are leaving off one parameter, namely 's', to keep the time the same.  i.e.,

  newdt2=intnx('dtday',datetime(),-1,'s') ;

Trusted Advisor
Posts: 2,115

datetime fields -1day is causing time to be 00:00.00

You are doing nothing wrong.  Check the "alignment" documentation for intnx.

http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#p10v3sa3i4k...

The "old fashioned" way to subtract one day from a datetime variable is to simply subtract 1 day's worth of seconds.

newdt = olddt - 24*60*60;

Doc Muhlbaier

Duke

Ask a Question
Discussion stats
  • 2 replies
  • 221 views
  • 0 likes
  • 3 in conversation