Hello everyone i want search data from invoices and client by today date I'm using DateDiff() GETDATE() functions for example two tables
1 Client
- ID int
- Name Varcher
2 Invoice
- ID int
- ClientID int
- date Datetime
- Total money
query
Select * from client c
inner join invoice i on c.id = i.ClientID
WHERE DateDiff(dd, i.date, getdate()) = 0
I want select query by specific day of current month and current year from date time if the current month is 08 and current year 2010 i want write any day of month Thanks every one help me
here is one way which will also be able to use an index
The simplest way to select records from a specific day in the current month and year is to declare a datetime variable assigned to the specified day, month and year, and replace
getdate()
in your query with the variable - like so:EDIT: To run a query for a specified day of the month in the current month, try the following: