I need to have the following funtion in Access converted into an MS SQL Server 2000 User-Defined Function. Would anyone be able to help? Or Would anyone know a book that offers the most often used user-defined functions such as first/last day of month, quarter, year, with an OPTIONAL parameter to pass, in MS SQL Server 2000?
' Get the last day of current month.
Public Function fncGetEndOfMonth(Optional dtmDate As Date = 0) As Date
' Did the caller pass in a date? If not, use the current date.
If (dtmDate = 0) Then
dtmDate = Date
fncGetEndOfMonth = DateSerial(Year(dtmDate), Month(Date) + 1, 0)