VB.NET - Working with DateAdd()



Cheat sheet for DateAdd() in VB.NET

'Adds date to the expression
        Dim year As Date = "2/1/2010"
        DateAdd("YYYY", 100, year)
        DateAdd("Q", 4, year)
        DateAdd("M", 12, year)
        DateAdd("D", 31, year)
        'adds 100 years to current date
        MessageBox.Show(DateAdd("YYYY", 100, year))
        'adds 4 quaters to current date
        MessageBox.Show(DateAdd("Q", 4, year))
        'adds 12 months to current date
        MessageBox.Show(DateAdd("M", 12, year))
        'adds 31 days to current date calulcating leap year or non leap 
        MessageBox.Show(DateAdd("D", 31, year))

Share |

 Cant find the page you are looking for?
 Help us to improve by adding the content that you are looking for.
 Leave a feedback
 We look forward to hear your comments and feedback.