If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Dates

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-20-05, 09:25
dimis2500 dimis2500 is offline
Registered User
 
Join Date: Jan 2005
Posts: 362
Dates

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
dimis
Reply With Quote
  #2 (permalink)  
Old 12-20-05, 09:39
dimis2500 dimis2500 is offline
Registered User
 
Join Date: Jan 2005
Posts: 362
Answer

I 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
Reply With Quote
  #3 (permalink)  
Old 12-22-05, 03:38
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
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)
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #4 (permalink)  
Old 12-22-05, 03:57
Jelly Link Jelly Link is offline
Registered User
 
Join Date: Dec 2003
Posts: 39
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.
__________________
Link Link
Reply With Quote
  #5 (permalink)  
Old 12-22-05, 07:06
dimis2500 dimis2500 is offline
Registered User
 
Join Date: Jan 2005
Posts: 362
Dates

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

Last edited by dimis2500; 12-22-05 at 07:20.
Reply With Quote
  #6 (permalink)  
Old 12-27-05, 20:57
Jelly Link Jelly Link is offline
Registered User
 
Join Date: Dec 2003
Posts: 39
to get current date and time use now(), month(now()) and year(now()) for current month and year
__________________
Link Link
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On