In future posts, we will explore building efficient data and analytics pipelines involving both technologies. For example, WEEK intervals are counted by Sundays rather than seven-day multiples from the from argument. It may support the years, months, weeks, days, etc. For example, the INTCK () can be used to determine how many months to generate. (To convert the SAS date value to a calendar date, use any valid SAS date format, such as the DATE9. You can use this function to calculate the number of days, weeks, months. The INTCK function using the default discrete method counts the number of times the beginning of an interval is reached in moving from the first date to the second. Person Day 1 Release Date Sales Person Day 2 Release Date Sales. (INTCK returns a negative value whenever the first date is. proc sql; select * from tableATo the macro processor everything is text, so quote characters are just part of the text. Syntax. The function INTCK ('MONTH','1feb1991'd,'31jan1991'd) returns –1 because the first date is in a later discrete interval than the second date. (To convert the SAS date value to a calendar date, use any valid SAS date format, such as the DATE9. This function uses the following basic syntax: INTCK(interval, start date, end data, method) where: interval: Interval to calculate (day, week, month, quarter, year, etc. What's the best way. With the %LET statement, you can create a macro variable named &start_dt and &stop_dt. . 4min 25s ± 0 ns per loop (mean ± std. . When dealing with months, it measures the number of "1st of the month" dates within the interval. 24574: Calculate the number of years, months, and days between two dates. . MAX_DATE ,MMD. 11 from Combining and Modifying SAS Data Sets - Examples. date1 = qtr (date): Extracts the quarter component from the. The INTCK function counts the number of interval boundaries between two date values or between two datetime values. Viewed 3k times. In binary arithmetic, 0. I am still not sure I understand what your looking to produce in the query. I have both these variables, but I am unable to figure out a proper syntax to get the de. . All of SAS's date handling would break. sas. of 1 run, 1 loop each) Intnx: Return the date (either the beginning or end of the month) after incrementing by given number of monthsAnalytics. DataFrame #. df["diff"] = np. BKD_DT, 1, "B") - t1. The INTCK function using the default discrete method counts the number of times the beginning of an interval is reached in moving from the first date to the second. if start is charecter then do as following. . 以下のデータセットがあったとします。. The SAS function to shift a date is INTNX(). 677. You can use the INTCK function in SAS to quickly calculate the difference between two dates in SAS. Whether you're a beginner or an advanced user, this tutorial offers a hands-on approach. 25, and INTCK) so that the results can be compared. Thus, at this article you will find few. ” Ron’s book reminds us that the “INTCK function counts how many times you cross a boundary going from the start date to the end date. Hello, I have a longitudinal dataset, where subjects are followed up for 2 weeks. timedelta (18). The INTCK function counts the number of interval boundaries between two date values or between two datetime values. POLICY_EFCTV_DT. For one thing, I still haven't quite figured out how to use R functions within a sqldf query, the same way I could use one of many SAS functions within PROC SQL. (end_dt) Parameter 4 is the method. There is an enormous difference between days since 1/1/60, and seconds since midnight, 1/1/60. – Cliff AB. . ①結果自体は、SASテクニカルサポート「年齢の計算方法」にあるやつと同じになる。. notedate :$11. com. To find the difference in values of variable between observations just use the DIF () function (related to the LAG () function). Renaming date variable to perform an intck to calculate day difference. ); 2. The INTNX function returns the SAS date value for the beginning date, time, or datetime value of the interval that you specify in the start–from argument. You cannot use the WHERE statement with the POINT= option in the SET and MODIFY statements. This simply consists of subtracting one month if the day number of somedateis earlier than the day number of. For the INTCK method, age is computed only as an integer. The rounding unit is a power of 10 greater than or equal to 1e-15. The form of the function is as follows: INTCK(‘<measured duration>’ , <DATEA>, <DATEB>); For example, if you wanted to measure the days that occurred between variable DATEA and DATEB, the. By default, Sunday is the beginning of the week interval. intck() returns the number of interval boundaries. Syntax of INTCK function: INTCK(interval , start-date-time, end-date-time, <'method'>) method: – It’s an optional parameter. SAS is headed back to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. The month interval is specified in this implementation: INTCK('month',dob,eventdate) . No problem. . Stock markets report opening and closing stock prices on trading days - generally equivalent to the "weekday" interval. The INTCK function using the default discrete method counts the number of times the beginning of an interval is reached in moving from the first date to the second. It easy to play with the dates using INTNX. The form of the INTCK function is INTCK( interval, from, to) where: interval is a character constant or variable containing an interval name from is the starting date (for date intervals) or datetime value (for datetime intervals) toSo to use INTCK() you need to convert those quoted strings into actual date values. sas. The INTCK() function will never return a non-integer value, because there isThe increment is based on a starting date, time, or datetime value, and on the number of time intervals that you specify. I used to do this with intck in SAS but lost all of my code and I can't remember how to get it right. It rounds off to the complete year i. I was wondering if any of the two methods below are appropriate and take care leap years as well. The SAS function, INTCK, serves as a way of determining a selected duration of time which has elapsed between two SAS variables. The syntax of INTCK function is as follows: INTCK (interval, start date, end data, method) interval: Interval to calculate (day, week, month, quarter, year etc. SAS stores datatime values in seconds. The function INTCK ('MONTH', '1feb2021'd, '31jan21'd) returns –1 because the first date is in a later discrete interval than the second date. You can create multiples of the intervals and shift their starting point. 25 methods, age is computed both as a decimal and an integer value. You could use the DAY interval. “day” or “month”. . Then print variables from that data set. The INTCK function counts the number of interval boundaries between two date values or between two datetime values. If you want today's year you can use the date () function (or its alias today ()) and then use the year () function to extract the year. First point - most other systems I've used use a base-dating system, whether it be 1Jan1960, 1Jan1901 or similar, and allow day arithmetic. (month) Parameter 2 is the start date. In addition the date values can also be aligned to start, mid or end of given interval. You need to convert it as you did in the INTCK calculations or add the key word CALCULATED to use the newly converted variable. . Hi ballardw. Finding the first day of the previous month is an ideal situation for using the INTNX function. format. Couldn't figure out why the intck function return wrong days. These functions are crucial for prediction, scheduling, trend analysis, and reporting. In this SAS tutorial, we will show you how to learn SAS programming on your own. Second your actual dates do not match the values you posted. These sample files and code examples are provided by SAS Institute Inc. By using multipliers and shift indexes, you can create multiples of intervals and shift their starting point to construct more complex interval specifications. The INTCK function returns the number of time units between dates. 1 Paper 261-30 Manipulating Data with PROC SQL Kirk Paul Lafler, Software Intelligence Corporation ABSTRACT PROC SQL isa popular database language with numerous extensionsfor working with numeric and character dataI need to calculate the difference between two dates in months. I tabulated the difference below. days=end - start + 1 ; Share. Ask Question Asked 3 years, 2 months ago. data temp; input ID TS HR; informat TS datetime20. This question is probably better suited for StackOverflow, as it is about programming not statistics. SAS INTNX() is the function that needs parameters like Interval, start_date, and a number of intervals to be added for a specified date value. It's joining two datasets using the amaskcd field as the key. SAS Tutorial For Beginners Date and Time Functions in SAS Date Functions with Use Case SAS Programming Tutorial For Beginners Functions in SAS INTCK Function. (INTCK renvoie une valeur négative chaque fois que la première date est postérieure à la deuxième date et que les deux dates ne sont pas dans le même intervalle discret. I'm trying to recreate a SURV_MM variable in the gold-standard dataset. I understand there still is a discrepancy with the yrdif function but unless there are no other options with intck to get a decimal the yrdif might be my only option. 2, a fifth argument to the INTCK function was added which will also help calculate a person's age. Difference between INTNX and INTCK Functions. These two functions complement each other: INTCK computes the difference between two dates, while. INTCK – The INTCK in SAS is a function that returns the number of time units between two dates. shift>’, date1,date2) Multiple(optional) = Multiple of intervalunit DAY50 = 50-DAY intervals Shift(optional) =starting point of interval Meaning of Shiftdepends on the Interval Interval=YEAR,SEMIYEAR,QTR,MONTH ÆShift= MONTH YEAR4. They are 'DISCRETE' (the default) and 'CONTINUOUS' (or "D" and "C"). The functions that can be used to take apart date values include: ) returns the day of the month from a SAS date value (. INTNX(interval, start date, increment <, alignment>). INTCK () is basically used to get the number of time intervals between two dates. 1. Data Mylib. Preparing and Analyzing Data. This function uses the following basic syntax: INTCK(interval, start date, end data, method) where: interval: Interval to calculation (day, week, month, quarter, year, etc. It's joining two datasets using the amaskcd field as the key. sas. comRounding by definition finds an exact multiple of the rounding unit that is closest to the value to be rounded. /*Comparing different ways of computing age*/. The intervals involving the date portion of a datetime variable in the Intnx or Intck functions start with DT, such as Dtday, Dtmonth, Dtquarter, Dtweek, Dtyear. seconds = datetime2 - datetime1 ; mintues = (datetime2 - datetime1)/60 ; You can also use the. . You can add the 'SAME" option if you want it to move to the same relative point in the interval. Accessing Data. workdays); From there, all you have left to do is something like this: data dateCalculations; set mydata; numOfDays = intck ("workdays", theDate, today ()); run; SAS will take care of counting the number of dates (lines in the workdays. sas. time; run; ThanksView the latest Intel Corp. 1 Answer. It does not count the number of complete intervals between two dates: The function INTCK ('MONTH', '1jan2021'd, '31jan2021'd) returns. e. One of the ones I am running into is the SAS SQL is using a condtional statement in a make. I. The INTNX () function knows about the MONTH interval but it knows nothing about an interval named 'MONTH'. SUBSTR extracts a portion of the value by stating. One of which best ways to understand the INTNX and INTCK functions and how they job is up see some easy examples. It will not print a function derived from other variables. ;intck most certainly can deal with variables -- in fact it deals with any expression that evaluates (implicitly or explicitly) to a number. Every single function in a %LET needs to be wrapped, including your INTCK () and MDY (). INTCK( 'datetime-interval', datetime1, datetime2) returns the number of boundaries of intervals of the given kind that lie between the two date or datetime values. So, although 22JUN2020 and 20JUL2020 belong to different months, the number of completed months between these. You can define a method to calculate differences. If the month falls in April, June, September, andINTCK counts the number of intervals between two dates, in our example we asked SAS to output the number of years between an employees data of birth and when they were hired which we would be equivalent to an employees age at the time of hire. INTCK ( interval, from, to ); The arguments of the INTCK function are as follows: interval. The intck function can return a negative value if the second value is less than the first. The variable current3 is assigned the 95th day of the 2008 year using the datejul( ) function. Example 3: Use INTNX to Find First Day of Month. No matter how many actual days are between them, I need the difference in month. intck () requires three arguments: an interval designator, and two SAS dates if a date interval is specified. Question eg: INTCK('QTR',FIN_YR,CNT_DATE)+5 What would provide me with the same answer in a SQL-Netzza code. The difference between these two dates is 10 days but just because the month has changed from March to April, the INTCK function (with discrete method) considers the difference between them to be 1 month. proc print data=kbc; run; I have one doubt also that intnx function I used above is also counting the days: this_month_first_date, next_month_first_date + days between them for total numbers days in month. org, written by Sieger Popovich. Appendixes. the "DTDAY" tells SAS the expected values are datetime, the DT part and you want DAY as the interval returned. /*Comparing different ways of computing age*/. If your teradata table is very large just for test get only few rows (Obs=10). When you use date and time intervals (for example, with the INTCK or INTNX functions), SAS bases its calculations on the calendar divisions that are present. This function is useful for creating intervals of a specific length between two points in time. You can use sas function intck to find required interval. I tried INTCK before with the following code, but it doesn't work for me (I get the same output). This was just an example to help you understand what it means. INTCK() DOES care whether the data variable is is seconds, etc. Example This program computes age using each of these methods (YRDIF, dividing by 365. Although there are other intervals available, the most commonly used intervals include 'day',. e. SELECT A. Re: How to extract a timestamp with one hour interval. SAS tracks dates as the number of days since January 1st, 1960. Improve this answer. The subjects each have a start and end date that is different. I need to find the difference between two dates in Pyspark - but mimicking the behavior of SAS intck function. However, the sas functions such as INPUT, PUT, INTCK etc do not work inside the CONNECT TO TERADATA sql query. , date and time intervals that don't have a direct proportional relationship to the base date or time units (days and seconds, respectively). INTCK is the function to return intervals between date, datetime or time values. “The INTCK function counts the number of intervals between the two dates and returns a number. You need to apply a format to the date value so it displays properly. ; datalines; 188 18Jul17:15:27:00 97 188. If the value of basis is AGE, then YRDIF computes the age. . 1055: Advances a date, time, or datetime value by a given interval, and returns a date, time, or datetime value : Interval functions : INTNX: day 14086. comFor more general on the INTCK and INTNX functions, see INTCK and INTNX: Second indispensable functions for computing intervals between dates in SAS, an article by @Rick_SAS. This function uses the following basic syntax: INTCK(interval, start date, end data, method) where: interval: Interval to calculate (day, week, month, year, etc. I need to do further task and I don;t know how to do it. Method 1: Age = INTCK ('year',dob,graduationdate,"C") Method 2: Age= (graduationdate-dob)/365. A DataFrame in pandas is analogous to a SAS data set - a two-dimensional data source with labeled columns that can be of different types. This was just an example to help you understand what it means. . Crossing a 'month boundary' does not necessarily mean that a completed month has elapsed so a correction needs to be made when the end date (somedate) is less than the. (INTCK returns a negative value whenever the first date is later than the second date and the two dates are not in the same discrete interval. . Then if the answer is yes write a check to see if the first day is a weekday. It covers a wide range of base and advanced tutorials that will help you get started with SAS. WEEK_NUM AS SELECT DISTINCT MUC. data new_data; set original_data; new_value1 = round (value, . In SAS 9. Note: The INTCK function returns the integer number of time intervals in a given time span. It's been a while working. . For example, you can use the INTNX functions to compute the scheduled that is 308 total in of future from. So you you need to reference the parameter value as &START_DATE, etc. 3. The first method "CONNECT TO TERADATA" is more efficient than the second method - LIBNAME statement as the first method hits the tables in teradata server and it would take less execution time. In other words, it returns the date value for 30APR1796. 21366 is the numeric representation of July 1st, 2018. This will work for months declared to begin on the 1st through 28th. Thanks a lot for your reaction! What I try to accomplish is the following: I have a dataset that has monthly observations for the following variables from CRSP (i. For example, in my previous article I used the INTCK function to ascertain the number to epoch between two dates. When the selected interval is 'year' it returns an integer number of years. The sample code on the Full Code tab illustrates how to determine the exact number of years, months, and days between two SAS date values. Divide 21 by 31 days will give you . The basic syntax of the INTNX function is. When I try to run the %let monthdiff=%sysfunc(INTCK(MONTH,date1,&lastdate)) line, I get the ERROR: Argument 2 to function INTCK referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number and then ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or. There is an enormous difference between days since 1/1/60, and seconds since midnight, 1/1/60. And it's pretty darned close. data example; date1 = '18Mar2021'd; date2 = '02Jul2021'd; default = intck ('month',date1,date2); cont = intck ('month',date1,date2,'C'); run; Decide what you would expect to be the number of months between those two dates (think perhaps of date1 as a. ); start date: The start date; end date: The end date; method: Whether to count. Use them with the INTCK and INTNX functions and with procedures that support numbered lists (such as the PLOT procedure). SAS 区间函数 INTNX 和 INTCK. Results. The function INTCK ('MONTH','31jan1991'd,'1feb1991’d) returns 1, because the two dates lie in different months that are one month apart. For instance, to my historical browse IODIN use the INTCK function at determine the count of days between dual dates. 25, and INTCK) so that the results can be compared. - SAS Help CenterContents Chapter 1 / Introduction to SAS Enterprise Guide . 1); /*round to 1 decimal place*/ new_value2 = round (value,. Modified 3 years, 2 months ago. The newly created variable new_x is in numeric format. A Series is the data structure that. ) returns the year from a SAS date value (. 33 rounded to the nearest tenth equals 3*0. For example: INTCK('MONTH','15MAR2018'd,11MAR2019'd) returns 12 even though the difference is less than 12 month (by 4 days). Solved: log_date cst_id 09Dec2016 101 20Jan2016 102 16Jul2015 103 The format of column "log_date" is DATE9. . Note: The INTCK function returns the integer number of time intervals in a given time span. So we will be using EMP_DET Table in. The INTCK Function is second to calculate the difference amidst two dates and times. No necessarily, if the start date lets say 2nd of the month, then it would only move the date back to 1st of the month. Partial intervals are not counted. Re: Nested SYSEVALF Errors in Macro. Re: INTCK Function and Rounding. Re: INTCK to compute minutes between dates. » SAS : INTCK Function with Samples. Month between two dates. Difference between INTNX both INTCK functions. ),input (booked_to,time5. Instead of adding just one interval, you can use the increment argument also to add multiple intervals to a. In SAS, date type variables contain the number of days between January 1, 1960, and the date specified. days=intck ("day", start, end+1); But since DATE values are just number of days you can also just subtract. ex. The INTNX function will compute an incremented date value, and allows the resultant interval alignment to be specified (in your case the 'end' of the month n-months hence) data have; format date_of_last_repricing end_date date9. For example, INTCYCLE('MONTH') returns 'YEAR' since the months January. Syntax INTCK in SAS: INTCK (‘Interval’, start_date, end_date) Interval – can be in minutes, seconds, hours,weeks, days, months,quarter and year. With DAY () function in SAS further you can extract day from that date. The SAS INTCK Function: Syntax. I know how to do it and you can see the code below. SAS INTNX ( ) function is one of the important date functions in SAS. Example. I could program this out, but I am guessing there is probably a format or function I'm not aware of to accomplish the task. The beauty of these functions is that they automatically handle leap years! If you request the number of days between two dates, the INTCK function includes leap days in the. NEAREST_MONTHS (date1, date2) Returns 8 if date1 is 20/3/1997 and date2 is 23/7/1996. For help clarifying this question so that it can be reopened, visit the help center . When using subtraction the order should be ENDDATE - STARTDATE. ) In this article, we discuss the syntax of the SAS INTCK function and provide many examples of real-world problems. Metadata. The time unit can be selected in years, months, weeks, days, or whatever you feel like. For example, the following statements give dates relative to the bombing of Pearl. A string containing a formatted date representation cannot be implicitly evaluated to a SAS number, it would have to pass through input . 前回、intck関数とintervaldsのコンボを紹介したので、次はintnx関数とintervaldsのコンボをやろうと思うのですが、まずintnx関数を使ったことない方も多いと思うので、基本を紹介します。. comThe INTCK function returns the number of intervals between two date values. I want to calculate precisely how much is the difference in number of months. Converting SAS PROC SQL to SQLITE queries in python - SAS intck function. len_in_mths = intck(‘month’,start_dt,end_dt,’c’); INTCK PARAMETERS What do the parameters for intck in the above example mean. difference=datetime1-datetime2; format difference time8. For the YRDIF and 365. Would you be able to answer why this happen if you know of. In this example, the first statement converts the values of cc , a numeric variable, into the four-character hexadecimal format, and the second statement writes the same value that the PUT function returns. "as is" without warranty of any kind, either express. First if you have macro parameters then they will be macro variables and not data step variables. Now we set up a custom interval which we'll simply call "workdays". I did a quick run of some "leap baby" years. Tenure of an employee with company : The INTCK function is used to find out the number of months between date of joining and today's date. to read the raw date values in. By example, in my previous article I utilised the INTCK function to determine the number of. i tried the code below : data eail ; infile cards dlm='09'x truncover ; input NO 1-2 Code $ Stn_Name: $25. Make your decision as to what you need to do! Also, here are some additional resources that may be helpful if you want to truly understand what is going on underneath the hood. Data set example: Subject_ID Date Obs 10 01/02/21 1 10 01/. cchex=put (cc,hex4. method: This is optional argument. . Looks as though you're using the explicit pass-thru access to TD, so you're limited to the TD=specific SQL syntax which, obviously doesn't support SAS functions like INTCK. 47 months. Many a times while working with dates we need to compare multiple dates and need to calculate the differences in days / months / years / quarters etc. 1, and not 0. SAS tem uma grande variedade de funções integradas que ajudam na análise e processamento dos dados. There is no need to use INTCK () when the interval you want is the basic storage unit of the data. CAS Action Programming with CASL, Lua, and Python. Looks like your time stamp values are numeric variables with datetime values. . INTCK measure the number of boundaries crossed. So just take the difference and apply the TIME format to have the number of seconds print in the tradition HH:MM:SS style. )); hours=intck ('hours',input (booked_from,time5. Posted 06-19-2016 02:35 PM (12054 views) Hi , I need to calculate age at graduation. If you want to convert the text value 20150301 to the text value 20148 (This is the SAS date of March 1, 2015), you can use the INPUTN function. Interested in speaking?Example 22. In the second example, INTCK returns a value of 1 even though only one day has elapsed. d format. . You need to specify dates, not datetimes. e. Which can be done as a "trunc then add" or a "add then trunc", via DATEADD, & DATE_TRUNC. time_Final; Diff = INTCK('second',Time_task_opened,Time_task_completed); set Mylib. Tutorial : INTCK Function Explained 44. Hello, This code has worked for me in the past, but not today. If the string is not found in source, INDEX returns a value of 0. The INTNX Syntax. If you only want to get the difference, irrespective of the order, use the ABS function around the INTCK. I'm trying to flag 30 days of data in my SAS code. Thanks,INTCK() DOES care whether the data variable is is seconds, etc. INTCK is most often used to calculate complex date and time intervals - i. The following SAS program creates a temporary SAS data set called createdates that contains six date variables. 2 Using Arrays in SAS® Programming Variables that are associated with an array have certain characteristics: All variables that are associated with an array must be of the same type, either character or numeric. AGE=INT((INTCK('MONTH',DOB,refDate) - (DAY(refDate)<DAY(DOB)))/12); I stopped using it when I discovered that the calculation would sometimes produce odd results. If the second date is later than the first date then 0 is returned. Release. This page lists all possible intervals. data _null_; sdate="12mar1998"d; edate="12jun2008"d; years=intck(‘year’,sdate,edate); put years; run; output:10 years To know the interval between 2 dates in days:. Assume I have 2 timestamp. To represent a date in a program just use a quoted string followed by the letter D. Hello SAS Community, I am working on a SQL and SAS data. ); run; In the above example, the variable x is a character variable as it is defined in quotes '12345'. Rather than asking for an R function equivalent to some SAS function, it sounds like you're just interested in computing the number of weeks. 1 Answer. Hello everyone, I am working with a dataset and carried out difference in recorded dates using the intck function as below: dif = intck ('day’, startdate, enddate, 'DISCRETE'); The sample result is shown below: dif frequency percent -6 18 0. Remove the extra run; statement that is ending the data step definition too soon. import pyspark. 000 diff2=2,962. Use INTCK to calculate the number of days between the patient’s current record’s date and the last date. The INDEX function searches source, from left to right, for the first occurrence of the string specified in excerpt, and returns the position in source of the string's first character. B) Using DATEDIFF() function with table column example. Again, it is best described by a few examples. . . Product. SAS provides date, time, and datetime intervals for counting different periods of elapsed time. It only returns hours (rounded up) and not minutes. So what I would do is first decide if you would k=like to count the first day. . The INTCK function counts intervals by using a fixed starting point for the interval as opposed to counting in multiples of the interval unit. As for 3): intck () does logically noting else than counting the rows in your working days table between two dates. The INTNX function returns the SAS date value for the. This is my code. is a character constant or variable that contains an interval name . Sorted by: 2. ) function. The INTNX function returning a SAS date that is a specified numeric of time units go from adenine stated date. 1. More specifically, it cares whether the value is a datetime value or a date value. Anniv = intnx ('year', '30APR1789'd, 7, 'same'); returns the 7th anniversary of the date 30APR1789. INTCK function returns the integer count of the number of interval boundaries between two dates, two times, or two datetime values. nmonths=intck('month',date1-1,date2-1); Just subtract 1 day less than the month starting day from both dates. The function INTCK ('MONTH','31jan1991'd,'1feb1991’d) returns 1, because the two dates lie in different months that are one month apart. e. SAS Servers. You provide the start time, the end time, and the desired interval, and the INTCK function returns the difference in seconds, minutes, or hours. The age computation takes into account leap years. Base SAS. In the below sample data, order_date is 02/22 (02/23 is weekend ) and 2 business days would be. The INTNX function returns the SAS date value for the beginning date, time, or datetime value of the interval that you specify in the start–from argument. a=Timestamp ('1986-03-31 00:00:00', tz=None) b=Timestamp ('1986-04-18 00:00:00', tz=None) Now if I simply take the difference b-a I will get datetime. 1. %let Start_Date=%sysfunc(inputn(20150301,yymmdd8));Yikes. 25. 05 -2 28.