How to substitute the DateSerial function to make my SQL execute in MS SQL Server
Posted on 2005-04-22
Is there a way to rewrite the code that follows, in Access, that I could place in a SQL string and execute in a MS SQL Server Stored Procedure:
I can't use the following code because DateSerial is not valid in MS SQL Server.
I need to take the date in tblA.dteA and compare it to 6/30th of the year determined by a user by selecting a year from a list box
named lstYear. The year selected is then reduced by the value in tblA.intProp.
tblA.dteA - value of a field from tblA (for ex: 02/22/1998)
lstYear - calendar year value selected from a list box (for ex: 2005)
tblA.intProp - value of a field from tblA (integer value of 1 or 2 or 3 or 4 or 5) (for ex: a value of 5
the WHERE CLAUSE I formerly used in my SQL string but which is not acceptable in MS SQL Server is as follows:
WHERE ((tblA.dteA <= DateSerial ("lstYear.Value) & "- tblA.intProp,6,30))
in my example above this WHERE clause translates to:
WHERE 2/22/1998 <= (2005 - 5) ,6,30 which translates to 2/22/1998 <= 6/30/2000