'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 number of days Public Function date2 () Dim newtime as datetime Newtime = datetime. Now. adddays (-7) Dim s as string = newtime Return s End Function 'Thanks to Paul czywcstmski for this idea 'This probably (in my opinion) offers the most flexibility found so far 'Change where the mm/DD/yyyy to whatever 'Response. Write (system. String. Format ("{0: d}", newtime )) 'Could return just the name of the day 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. tow.timestring () 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. tow.datestring () 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 Updated Date 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 processing time 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 day 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 'Very flexible with not a lot of code Function date17 () Dim mydate as string Mydate = format (now (), "YYYY ") Return mydate End Function </SCRIPT> |