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

Variable in DateDiff()

Status
Not open for further replies.

jalbao

Programmer
Joined
Nov 27, 2000
Messages
413
Location
US
How do I use a variable inside of the DateDiff function?

Here's what I want to do:

SELECT *
FROM tblSchedule Sch
JOIN tlkpTimeFrame TF ON Sch.lTimeFrameID = TF.lTimeFrameID WHERE Sch.lRecur > 0
AND datediff('TF.sDatePart',Sch.dtStartTime,getDate()) % Sch.lRecur = 0

You'll notice that in parameter 1 of the DateDiff function I have placed the name of a field taken from the tlkpTimeFrame table. The sDatePart field will contain one of the datepart types (n,m,hh,yy etc).

I am trying to figure out a way to programatically generate the datepart of the DateDiff function by the sDatePart value for each record.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top