asp.net| function ' Uses the Timespan method to subtract a certain number of days
Function Date1 ()
Dim NewTime as DateTime
NewTime = DateTime.Now.Subtract (New TimeSpan (7, 0, 0, 0))
NewTime = Newtime.format ("mm/dd/yyyy", DateTimeFormatInfo)
Response.Write (NewTime)
End Function
' Uses the AddDays method to subtract X # of Days
Public Function Date2 ()
Dim NewTime as DateTime
NewTime = DateTime.Now.AddDays (-7)
Dim s As String = NewTime
return s
End Function
' To Paul Czywczynski for this idea
' This probably (in my opinion) offers the most flexibility found so far
' Change where ' mm/dd/yyyy to whatever
' Response.Write (System.String.Format ("{0:d}", NewTime))
' Would return just the name of the '
Function Date3 ()
Dim newtime as DateTime = Now.adddays (-7)
Response.Write (System.String.Format ("{0:mm/dd/yyyy}", NewTime))
End Function
Function Date4 ()
Dim NewTime as DateTime
NewTime = Now.adddays (-7)
Return newtime.tostring ()
End Function
' Uses the Tolongtimestring method
Public Function Date5 ()
Dim NewTime as DateTime
NewTime = Now ()
Return newtime.tolongtimestring ()
End Function
' Uses the Toshorttimestring method
Public Function Date6 ()
Dim NewTime as DateTime
NewTime = Now ()
Return newtime.toshorttimestring ()
End Function
' Uses the Tolongdatestring method
Public Function Date7 ()
Dim NewTime as DateTime
NewTime = Now ()
Return newtime.tolongdatestring ()
End Function
' Uses the ToShortDateString method
Public Function Date8 ()
Dim NewTime as DateTime
NewTime = Now ()
Return newtime.toshortdatestring ()
End Function
' Uses FormatDateTime function general format
Function Date9 ()
Dim NewTime as DateTime
NewTime = DateTime.Now.Subtract (New TimeSpan (7, 0, 0, 0))
Return FormatDateTime (newtime, 0)
End Function
' Uses formatdatetime function longdate format
Function Date10 ()
Dim NewTime as DateTime
NewTime = DateTime.Now.Subtract (New TimeSpan (7, 0, 0, 0))
Return FormatDateTime (NewTime, 1)
End Function
' Uses formatdatetime function shortdate format
Function Date11 ()
Dim NewTime as DateTime
NewTime = DateTime.Now.Subtract (New TimeSpan (7, 0, 0, 0))
Return FormatDateTime (NewTime, 2)
End Function
' Uses formatdatetime function longtime format
Function Date12 ()
Dim NewTime as DateTime
NewTime = DateTime.Now.Subtract (New TimeSpan (7, 0, 0, 0))
Return FormatDateTime (NewTime, 3)
End Function
' Uses formatdatetime function shorttime format
Function Date13 ()
Dim NewTime as DateTime
NewTime = DateTime.Now.Subtract (New TimeSpan (7, 0, 0, 0))
Return FormatDateTime (NewTime, 4)
End Function
' Bring back just the name of the '
Function Date14 ()
Dim newtime as DateTime = Now.adddays (-7)
Dim s As String
s = (System.String.Format ("{0:dddd}", NewTime))
return s
End Function
' Returns the Integer of what day of week
Function Date15 ()
Dim MyDate as DateTime
Dim Myweekday as Integer
MyDate = Now.adddays (-5)
Myweekday = Weekday (mydate)
Return Myweekday
End Function
' Returns the Month Integer
Function Date16 ()
Dim MyDate as DateTime
Dim Mymonth as Integer
MyDate = Now.adddays (-5)
Mymonth = Month (mydate)
Return Mymonth
End Function
' Returns just a formatted string
' This method provides just formatting but
' Very flexible with not a lot of code
Function Date17 ()
Dim MyDate as String
MyDate = Format (now (), "yyyy")
Return mydate
End Function
</script>