•      Powered by
 

Various Ways of Subtracting Time from a Current Date

Back to the article

'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 Czywczynski 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))
'would 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

 

Method #1 -- Various Ways of Subtracting Time from a Current Date Method #2 -- General Formatting Techniques 
Method #3 -- Using FormatDateTime Function Method #4 -- Display Specific parts of the Date(DAY, MONTH, TIME)
 

tio

Terms of Use | Privacy Statement ©2005-2006 IISLogs.com. All rights reserved - Powered by IIS7 - info @ www.IIS.net