Advertisement
Guest User

sathish1

a guest
Feb 18th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. Module DateTimeExtensions
  2. <Extension()>
  3. Function AddHalfMonth(ByVal dt As DateTime) As DateTime
  4. Dim daysInMonth As Integer = System.DateTime.DaysInMonth(dt.Year, dt.Month)
  5.  
  6. If daysInMonth Mod 2 = 0 OrElse dt.Day < daysInMonth / 2 Then
  7. Return dt.AddDays(daysInMonth / 2)
  8. End If
  9.  
  10. Return dt.AddDays((daysInMonth + 1) / 2)
  11. End Function
  12. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement