Positive dates until new year?

I’d like to have a date difference calculation that brings the number of days until the next new year (Jan 1). What would be the best way to execute this? I’m not really sure how to find the date difference between now/today and a date with no year element.

I’m sure that @Jeff_Hager will be able to give you a single math column to do this, but in the meantime here is a 3 column solution:

Start by using a math column to get Jan 1 as an integer in the format YYYYMMDD:

(Year(Now)+1)*10^4 + 101

Convert that to an actual date using a Text to Date column (using your own timezone):

And then use a second math column to subtract the current date:

Trunc(J1-Now)

The end result should look like this:

1 Like

Another way to do it would be to cheat and use a single JavaScript column:

return Math.floor((new Date(new Date().getFullYear() + 1,0,1) - new Date()) / (24*60*60*1000));

3 Likes

Thanks! I like the cheat Javascript, but I also like knowing how to do it without Javascript since I don’t understand Javascript.