Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date

Status
Not open for further replies.

fmardani

Programmer
Jul 24, 2003
152
Hi,
How is it possible to get the date for 7 days ago please?
Thanks
 
Hi,

Simple, just create a function and pass to the function how many days you want.

Dim last_seven_days_date As DateTime = GetPassDays(Today, -7)

Public Function GetPassDays(ByVal DateIn As DateTime, _
ByVal WhichDate As Integer) As DateTime
Dim datDate As DateTime = DateIn.AddDays(WhichDate)
While Weekday(datDate) = 1 Or Weekday(datDate) = 7
datDate = datDate.AddDays(IIf(WhichDate < 0, -1, 1))
End While
Return datDate
End Function

Hope this helps :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top