on 05-20-2008 11:23 PM
I created a query and want it to filter based on todays date. How do I automatically add todays date to the query so the user does not need to type it in?
Hi,
Use the getdate() function for todays date. For example, select * from OJDT T0 where T0.refdate >= getdate() will return all the fields for journals posted with today's date.
HTH
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes you are right. You will need to use WHERE convert(varchar, T0.refdate, 103) = convert(varchar, getdate(), 103)
This is because the getdate() is actually a datetime field and returns current date and current time so in the previous statement you are asking for journal fields where the posting date = todays date AND the exact time that the query is run which is never going to be true.
If you just use getdate()-1 you will also get yesterdays' journals posted after this time yesterday.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.