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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing a DateTime field to a Date field.

Status
Not open for further replies.

chiplarsen

IS-IT--Management
Jan 8, 2004
87
US
I have a DateTime field that I need to use in my Where statement. I need to use it as a Date. I want to say that a Charge Date is Date -1. That will give me yesterdays date. How do I convert the date time to date? Thank you
Code:
    On Error Resume Next
 
  Set cnSQL=CreateObject("ADODB.Connection")
  cnSQL.Open "DSN=MMLIVE;UID=wl2817;PWD=wl2817"

 
  Set rsMMLIVECHARGEVIEW=CreateObject("ADODB.Recordset")
  rsMMLIVECHARGEVIEW.Open "Select * From HCS.Charges_View where PCU = 'GNE'" ,cnSQL
  Do While Not rsMMLIVECHARGEVIEW.EOF
  
  WScript.Echo rsMMLIVECHARGEVIEW("PCU")&" "&rsMMLIVECHARGEVIEW("Date of Charge")&" "&rsMMLIVECHARGEVIEW("DOSEQUANTITY")&" "&rsMMLIVECHARGEVIEW("CHARGE")

      rsMMLIVECHARGEVIEW.MoveNext
      Loop
 

'***** Close *****
  cnSQL.Close
'*****
 
You can use the day(date), month(date) and year(date) to get the date without time and the dateadd function to get the previous date.

dateadd("d", -1, date)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top