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 2005 Forums
 Transact-SQL (2005)
 How to make daily report with current date

Author  Topic 

Jagger
Starting Member

3 Posts

Posted - 2010-06-07 : 19:16:54
Hi,

I have a table with daily visits from sales persons.
In this table there are few attributes for example....salesperson, customer name, address, main contact and date of the visits like 05.22.2010 13:46:40.
I would like to make daily report which shoould be in real time with some command in order to get always current date.
It means that any manager or user in our company when press button for this report get always all visits per salesperson on current date.
Is it possible to make something like this?
How to make this report?
regards

Jagger

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-06-07 : 19:31:37
where dateColumnInyourTable >= dateadd(day,datediff(day,0,getdate()),0)

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

Jagger
Starting Member

3 Posts

Posted - 2010-06-07 : 20:06:00
Thanks.
What to do if I have date in this format 05.22.2010 13:46:57

If I try to execute this command:

select date
from visits
where date >= dateadd(day,datediff(day,0,getdate()),0)

I get this error message:


An expression of noon-bolean type specified in a context where a condition is expected, near date

what is a problem?

Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-06-07 : 20:21:25
The format should be fine. You probably have a syntax error somewhere. Your query works when I run it. Could you post the query that is giving you this error? Try putting date in brachets first
select [date]
from visits
where [date] >= dateadd(day,datediff(day,0,getdate()),0)

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-06-08 : 02:30:03
quote:
Originally posted by Jagger

Thanks.
What to do if I have date in this format 05.22.2010 13:46:57

If I try to execute this command:

select date
from visits
where date >= dateadd(day,datediff(day,0,getdate()),0)

I get this error message:


An expression of noon-bolean type specified in a context where a condition is expected, near date

what is a problem?




This error will occur only if you run

select date
from visits
where date

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Jagger
Starting Member

3 Posts

Posted - 2010-06-08 : 03:30:12
It works now. I forgot to make brackets.
Thanks to all.
Go to Top of Page
   

- Advertisement -