9 Replies Latest reply on May 18, 2016 3:09 AM by Mahfooj Khan

# How to calculate number of days difference between sysdate date and a fixed date w.r.t sysdate

I have a query. In a formula i want number of days difference between 2 dates. 1st date is sysdate(Now()) and 2nd date would be 1st June( that has last passed).

e.g If 1st date is  1/July/2015 than 2nd date should be 1/june/2015

If 1st date is 1/Jan/2016 than 2nd date should be 1/June/2015.

How do i calculate the second date?

• ###### 1. Re: How to calculate number of days difference between sysdate date and a variable date

try this

makedate

`MAKEDATE(2015, 6, 1) = #june 1, 2015#`

` `

datediff('day',sysdate,makedate)

or if date is today

datediff('day',today(),makedate)

• ###### 2. Re: How to calculate number of days difference between sysdate date and a variable date

My question is how will we select year for makedate. makedate(which_year,6,1)

Let me repeat my examples

e.g If 1st date is  1/July/2015 than 2nd date should be 1/june/2015.

If 1st date is 1/Jan/2016 than 2nd date should be 1/June/2015 and NOT 1/June/2016

we should get the date of last June that has passed.

• ###### 4. Re: How to calculate number of days difference between sysdate date and a variable date

Hi,

Please check the attached workbook 9.3 version

For the steps you can loo into this article:Difference in Dates with One Date Field | Tableau Software

• ###### 5. Re: How to calculate number of days difference between sysdate date and a variable date

Hi Swapnil,

Thanks msa s for ping.

Tharashasank Davuluru has already given you the solution how to get the datediff from two dates. However I'm giving you another way of getting datediff from past june and variable date(parameter date). Have a look. Workbook (version 9.2) attached below. Let us know your remarks.

Mahfooj

• ###### 6. Re: How to calculate number of days difference between sysdate date and a variable date

Unable to attach the workbook

• ###### 7. Re: How to calculate number of days difference between sysdate date and a variable date

Trying to attach the workbook once again.

• ###### 8. Re: How to calculate number of days difference between sysdate date and a variable date

• ###### 9. Re: How to calculate number of days difference between sysdate date and a fixed date w.r.t sysdate

I don't know how much this will help you. However you can try this

Mahfooj