LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2003, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 19 Nov 2003 12:36:38 -0500
Reply-To:   Peter Crawford <peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Peter Crawford <peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Subject:   Re: Difference in days between two different SAS dates
Comments:   To: Gerhard Hellriegel <ghellrieg@T-ONLINE.DE>

On Wed, 19 Nov 2003 12:14:02 -0500, Gerhard Hellriegel <ghellrieg@T- ONLINE.DE> wrote:

>... the only problem might be: the results are negative. You can use the >ABS function for that or flip the variables.

an alternative solution to that negative result problem could be :

diffday = range( datevar1, datepart( datevar2) );

> >On Wed, 19 Nov 2003 08:55:26 -0600, Gary Ross <gary_ross@MGIC.COM> wrote: > >>Leslie Fisher wrote: >>> >>> Hi, >>> I have a rather simple problem, but cannot get it done. I just want to >>> compute the difference in days between two SAS date variables (DATEVAR1 >>> and DATEVAR2). SAS says, DATEVAR1 has ddmmyy9. and DATEVAR2 has >>> DATETIME20. format. >>> DATEVAR1 DATEVAR2 The result could look like DIFFDAY >>> 24/11/97 25NOV1997:00:00:00 1 >>> 14/12/00 16DEC2000:00:00:00 2 >>> 17/02/00 21FEB2000:00:00:00 4 >>> 17/07/00 10DEC1999:00:00:00 etc. >>> 29/09/00 09DEC1999:00:00:00 >>> ... >>> Thanks a lot in advance, >>> Leslie >> >>Leslie >> >>You need to apply the datepart function to the datetime variable like >> >>diffday = datevar1 - datepart(datevar2) ; >> >>HTH


Back to: Top of message | Previous page | Main SAS-L page