• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1080
  • Last Modified:

asp sql syntax - current date- datediff

What's the best way to get the current date in this query instead of the hard coded 10/15/2007?

I've tried a couple scenarios with no luck.  <%response.write(date())%> and (date())

conn.open "SELECT id, date1, EmpName, Software, Hardware, Comments, Status, date2, Comments2, Tech, Priority, DATEDIFF('d', date2, '10/15/2007') AS testouput FROM helpdesk WHERE (Status = 'closed') AND (DATEDIFF('d', date2, '10/15/2007') < " & daysback & " ) ORDER BY id DESC;", "DSN=helpdesk"

ideas?
0
bschwarting
Asked:
bschwarting
1 Solution
 
Rey Obrero (Capricorn1)Commented:
in access you will just use Date()
try this anyway


conn.open "SELECT id, date1, EmpName, Software, Hardware, Comments, Status, date2, Comments2, Tech, Priority, DATEDIFF('d', date2, Date()) AS testouput FROM helpdesk WHERE (Status = 'closed') AND (DATEDIFF('d', date2, Date()) < " & daysback & " ) ORDER BY id DESC;", "DSN=helpdesk"

or

conn.open "SELECT id, date1, EmpName, Software, Hardware, Comments, Status, date2, Comments2, Tech, Priority, DATEDIFF('d', date2, Date) AS testouput FROM helpdesk WHERE (Status = 'closed') AND (DATEDIFF('d', date2, Date) < " & daysback & " ) ORDER BY id DESC;", "DSN=helpdesk"
0
 
chisholmdCommented:
if this is ms sql use getdate()

eg.
DATEDIFF('d', date2, getdate())
0
 
bschwartingAuthor Commented:
Date() worked great, thanks!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now