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

How to use current year -1

Status
Not open for further replies.

tbonehwd

IS-IT--Management
Jul 28, 2005
45
US
On my form I have a place for the user to enter a from date and an end date. I want to create another query based on the date the user enters -1 year. Below is the code I currently have to get the date from the form.

Code:
        If IsNull(Me.txtFRMDATE.Value) Then
        MsgBox "You must specify a Start Date. Press OK and enter the Start Date"
        Exit Sub
    Else
        strFRMDATE = ">=#" & Me.txtFRMDATE.Value & "# "
    End If
    If IsNull(Me.txtTODATE.Value) Then
        MsgBox "You must specify a End Date. Press OK and enter the End Date"
        Exit Sub
    Else
        strTODATE = "<=#" & Me.txtTODATE.Value & "# "
    End If

In my where clause I want the strFRMDATE and strTODATE to be equal to what the user enters -1 Year.

Code:
         "AND PROORD_M.ACT_DTE " & strFRMDATE & _
         "AND PROORD_M.ACT_DTE " & strTODATE & _

Can this be done and if so how?
 
you need to use DateAdd() function....

DateAdd(yyyy,-1,mydate)

-DNG
 
and this can be used in the where statement with a string?

 
something like this...

WHERE yourDate=DateAdd("yyyy",-1,now())

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top