DateSerial Functions???

  • Thread starter Thread starter SteveL
  • Start date Start date
S

SteveL

I have a form with serveral date fields on it. Am
looking for help on the DateSerial syntax to use for the
following default values:

The first day of the current month.

The first day of the current month one year ago.

The last day of the current month one year ago.

The first day of the current year.

Any help anyone can provide will sure be appreciated.

--Steve
 
Public Function FirstOfCurrentMonth() As Date
FirstOfCurrentMonth = DateSerial(Year(Date), Month(Date), 1)
End Function

Public Function FirstOfCurrentMonthYearAgo() As Date
FirstOfCurrentMonthYearAgo = DateSerial(Year(Date) - 1, Month(Date), 1)
End Function

Public Function LastOfCurrentMonthYearAgo() As Date
LastOfCurrentMonthYearAgo = DateSerial(Year(Date) - 1, Month(Date) + 1,
0)
End Function

Public Function FirstOfCurrentYear() As Date
FirstOfCurrentYear = DateSerial(Year(Date), 1, 1)
End Function
 
Andrew...

Thank You!

--Steve

-----Original Message-----
Public Function FirstOfCurrentMonth() As Date
FirstOfCurrentMonth = DateSerial(Year(Date), Month (Date), 1)
End Function

Public Function FirstOfCurrentMonthYearAgo() As Date
FirstOfCurrentMonthYearAgo = DateSerial(Year(Date) - 1, Month(Date), 1)
End Function

Public Function LastOfCurrentMonthYearAgo() As Date
LastOfCurrentMonthYearAgo = DateSerial(Year(Date) - 1, Month(Date) + 1,
0)
End Function

Public Function FirstOfCurrentYear() As Date
FirstOfCurrentYear = DateSerial(Year(Date), 1, 1)
End Function




.
 
I have a form with serveral date fields on it. Am
looking for help on the DateSerial syntax to use for the
following default values:

The first day of the current month.

DateSerial(Year(Date()), Month(Date()), 1)
The first day of the current month one year ago.

DateSerial(Year(Date())-1, Month(Date()), 1)
The last day of the current month one year ago.

DateSerial(Year(Date())-1, Month(Date())+1, 0)
The first day of the current year.

DateSerial(Year(Date()), 1, 1)
 
Back
Top