Results 1 to 6 of 6

Thread: Dates

  1. #1
    Join Date
    Jan 2005
    Posts
    362

    Unanswered: 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

  2. #2
    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

  3. #3
    Join Date
    Sep 2004
    Location
    Belgium
    Posts
    1,126
    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/

  4. #4
    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

  5. #5
    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 08:20.

  6. #6
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •