# Number of Days Calculation

Ok, trying to keep this as easy as possible.  I need to find the best way to find out how many days from the beginning of a year to a date that is entered by the user into a text box.

Dim DateEntered as Date
Dim NumDays as Long

DateEntered = TextBox1.value
This is probably where I need to take the year from the date and work with that, which is my ??
NumDays = DateEntered - ??
###### Who is Participating?

Commented:
sorry for making repetitive mistakes.
this should work:-

``````Dim DateEntered As Date
Dim NumDays As Long
DateEntered = CDate(TextBox1.text)
Dim YearStartDate As Date = CDate("1/1/" & Today.Year)
NumDays = DateDiff(DateInterval.Day, YearStartDate, DateEntered)
``````
0

Commented:
``````Dim DateEntered As Date
Dim NumDays As Long
DateEntered = CDate("TextBox1.text")
Dim YearStartDate = CDate("1/1/" & Today.Year)
NumDays = DateDiff(DateInterval.Day, YearStartDate, DateEntered)
``````
0

Commented:
sorry some corrections:-
``````Dim DateEntered As Date
Dim NumDays As Long
DateEntered = CDate(TextBox1.text)
Dim YearStartDate = CDate("1/1/" & Today.Year)
NumDays = DateDiff(DateInterval.Day, YearStartDate, DateEntered)
``````
0

Commented:

``````Dim DateEntered As Date
Dim NumDays As Long
DateEntered = CDate(TextBox1.text)
Dim YearStartDate As Date = CDate("1/1" & Today.Year)
NumDays = DateDiff(DateInterval.Day, YearStartDate, DateEntered)
``````
0

Author Commented:
Works very nice.  The only change was since it might not be this year, I used "CDate("1/1/" & DateEntered.Year)