dim y as string = Date.Today.year dim m as string = Date.Today.month if m = 1 Dim Days As Integer = Date.DaysInMonth(y,13-1) dim dt as date = Date.Today.adddays(-days) else Dim Days As Integer = Date.DaysInMonth(y,m-1) dim dt as date = Date.Today.adddays(-days) end if