# Just for fun: Christmas Countdown function



## Scott Huish (Oct 28, 2014)

If you don't specify a year, it will use the current one.


```
Function Christmas(Optional yr As Long) As Long
If yr = 0 Then yr = year(Now)
yr = yr + 1
If Date > DateSerial(yr, 12, 25) Then yr = yr + 1
Christmas = (DateSerial(yr, 1, 1) - 6) - Date
End Function
```


----------



## BiocideJ (Oct 28, 2014)

LOL. Too soon. 

I think there is an error in your calculation though because on 12/25/14 =Christmas(2014) will return 1...
I think it should be Christmas = (DateSerial(yr,1,1)-7)-Date

In testing it I also added a new optional argument so that you can specify any start date to so you can see how many days old you will be this Christmas ala
=Christmas(2014,DateValue("yourbirthdate")) 
 I totally fell into the Christmas in October trap.



```
Function Christmas(Optional yr As Long, Optional fromDate As Date) As Long
    If fromDate = 0 Then fromDate = Date
    If yr = 0 Then yr = Year(fromDate)
    If fromDate > DateSerial(yr, 12, 25) Then yr = yr + 1
    Christmas = (DateSerial(yr, 12, 25)) - fromDate
End Function
```


----------



## Rick Rothstein (Oct 28, 2014)

BiocideJ said:


> LOL. Too soon.









Well, if we are going to rush the season...  A Blinking Christmas Tree


----------



## TinaP (Oct 29, 2014)

I admit, I've already started my shopping.  I just can't handle the crowds anymore and frankly, I'd rather be carrying packages in cool, but not icy weather.


----------



## Snakehips (Nov 1, 2014)

Too soon, too soon!!!

Spare thought for those of us who are allergic to seasonal good will, merriment, roast turkey, tinsel and blinking christmas trees!!!

With that in mind I have modified Scott's UDF with a view to, perhaps, giving it broader scope......


```
Function Christmas(Optional BahHumbug As Boolean, Optional yr As Long) As String

If yr = 0 Then yr = Year(Now)
yr = yr + 1
If Date > DateSerial(yr, 12, 25) Then yr = yr + 1
NumDays = (DateSerial(yr, 1, 1) - 7) - Date
Txt = " days until Christmas!!"


  If BahHumbug = True Then
        Pre = "Oh no...   "
        CDay = "Blinkin'eck, it's a bit slow on the forum today!"
    Else
        Pre = "Whoopeee...   only "
        CDay = "MERRY CHRISTMAS!!"
  End If


 If NumDays > 0 Then
       Christmas = Pre & NumDays & Txt
  Else
      Christmas = CDay
 End If


End Function
```


----------

