I want to make a simple question.
I want to query the count of the records at a table for a month (mm/yyyy), how i have to "format" the date for this in access?
Thanks
dimisI had this answer from pootle flump in forum of access
Hi
You can either use a range in your where clause (WHERE MyDate BETWEEN 1st day of month and Last day of month) or you can use some functions (probably a little slower - WHERE Year(MyDate) = TheYearIWantToCheck AND Month(MyDate) = TheMonthIWantToCheck)
HTH
__________________
Environment: A02\03 SQL Server 2K DAO 3.6 ADO 2.7 VB6 SP5
Reply With Quote|||Note that the range solution (WHERE MyDate BETWEEN '2005-12-01' AND '2005-12-31') is typically much more performant (and more portable too ;)) than the use of scalar functions (WHERE year(MyDate)=2005 AND month(MyDate)=12)|||dont use short date format for date comparison, coz every single second affects the result. '2005-01-01' means '2005-01-01 00:00:00.000', no more no less, even just 1 second. so i used to use function like year, month, day, datediff.|||My problem was that I had to find the records from a table for the current month (in Ms access with asp) so I had to find dynamicaly the current month and then find the correct sql statement.
dimis|||to get current date and time use now(), month(now()) and year(now()) for current month and year
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment