DateSerial Functions???

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
 
A

Andrew Smith

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
 
S

SteveL

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




.
 
J

John Vinson

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top