Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Pulling records by current date

Author  Topic 

the ase in database

9 Posts

Posted - 2007-08-27 : 07:06:34
Hi,
I've just joined this forum in the hope that someone can answer this question for me - sorry if this is a rookie question, but i'm new to this game. I am building a reporting application that has to be able to pull records based on the current date. The sql command will be embedded in a vb.net application so i can't change the query to hard code the current date each time management need to generate a report. i was looking at the get_date() function along with others, but don't really know if it is possible using these functions. Does anyone have a clue? Apologies oncemore if this is a rookie question.
kind regards to all

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-27 : 07:10:21
You are not alone! This rookie question is asked and answered at least three times per day, because no-one is willing to search for information, only begging for it.

SELECT *
FROM Table1
WHERE Column1 >= DATEADD(DAY, DATEDIFF(DAY, 0, CURRENT_TIMESTAMP), 0) -- Today
AND Column1 < DATEADD(DAY, DATEDIFF(DAY, 0, CURRENT_TIMESTAMP), 1) -- Tomorrow

Replace CURRENT_TIMESTAMP with your date variable instead.
And use parameters when calling the database. DO NOT use dynamic SQL.




E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -