NNKL.COM
welcome to my space
X
Search:  
 HOME   Access 97 - Query To Extract Only The Date From Date/Time Field
Access 97 - Query To Extract Only The Date From Date/Time Field
Published by: anonym 2009-01-07
Welcome to:nnkl.com

  • Hi -

    I'm using MS-Access 97 and I need to be able to write a query to extract distinct dates from date/time fields. Just the date, not the time. I have many records with identical dates but different times.

    Background: I am giving users a picklist that is supposed to allow users to select a date from the list and then get a report of all records for that date, regardless of time. So, I need to show only ONE "date" per date on the picklist no matter how many records have that date. Currently, I'm able to display each date in the picklist without the time, but each date in the picklist may appear multiple times if there are multiple records for that date. Example:

    What I get now:

    3/8/2004
    3/8/2004
    3/9/2004
    3/10/2004
    3/10/2004
    3/10/2004

    What I want to see:

    3/8/2004
    3/9/2004
    3/10/2004

    Thanks for any help!!


  • Yes I guess you would. I should read my own SQL

    Select Distinct Format([YourDateField],"mm/dd/yyyy") From [YourTable];

    SELECT DISTINCT Format([YourDateField],"mm/dd/yyyy") as MyDate
    FROM [YourTable;


    or

    SELECT DISTINCT cdate(datevalue([yourdatefield]) as MyDate FROM [yourtable];

    That should help. I forgot when using a formula, you have to tell access what to call the field hence the "as MyDate" verbiage. You can of course call the field anything you want to.


  • No luck with this one, either. Get same result as previous, where it seems not to be able to "see" the column name in the query.
  • Pennsylvania Geological Survey: PaGWIS::
    Each button on the forms initiates an Access query that reads the data from the when we want to extract only a single owner for each well or spring.
    http://www.dcnr.state.pa.us/topogeo/groundwater/pagwis/help.aspx
    HOME


  • Unfortunately, when I try this, then try to list the query results, I get a ColdFusion error message that says that my date/time column was "not present in the query".

    If I say "SELECT DISTINCT MyDateTimeField" (my original query), I get results, but when it is written "SELECT DISTINCT DateValue([MyDateTimeField])", ODBC seems not to be able to see the field when doing the query. Maybe it thinks "DateValue" is the column? I'm pretty new at all this---it seems like this should be a fairly simple thing to do, but it's giving me fits!


  • i don't know cold fusion.
    maybe it doesn't like the "Date" data type.
    try changing it to a String value

    Select Distinct CStr(DateValue([YourDateField])) From [YourTable];


  • I wonder if it's taking it out of a date format try:
    Select Distinct Format([YourDateField],"mm/dd/yyyy") From [YourTable];

    or

    Select Distinct cdate(datevalue([yourdatefield]) from [yourtable];

    let us know


  • Actually, the list will be on an html form as a regular html picklist and generated by ColdFusion accessing the db via ODBC. So, I need to be able to get just the "date" part of the date/time field.


  • If your using a listbox, open the form in design view, select your listbox, right click and click properties. then select the Data Tab. In the Row Source field there should be an SQL statement like

    Select [YourTable].[YourDateField] From [YourTable]

    Change this to
    Select Distinct [YourTable].[YourDateField] From [YourTable]

    This should sort it


  • Select Distinct DateValue([YourDateField]) From [YourTable];


  • When I tried the first way, I got ODBC Error Code 07001 "Wrong Number of Parameters - Expected 1"

    When I tried the second way, I got ODBC Error Code 37000 "Syntax Error or Access Violation - Wrong Number of Arguments Used":confused:





  • I Am a Sinner – What About You?
    Global Sourcing and Supplier Online by Dylan

    You are looking at:nnkl.com's Access 97 - Query To Extract Only The Date From Date/Time Field, click nnkl.com to home
  • how do i sub 1 2 cub brown sugar
  • aghhh i kinda want him back
  • i need legal advice on how to get something done with my evidence of a crime and no one does anything
  • gentlemen how do you feel about an entire generation of women being tattooed
  • do you like tattoos on men and women
  • poll where do you work and do you like working there
  • grape dishes alot of people
  • who invented abortion
  • men women would you ever get tattoos
  • how may i be obligated to medical bills for my non custodial children
  • to women who know what happens to tattoos on your stomach when you are pregnant
  • if you were an alien
  • what do you think is the number limit for tattoos for woman to have
  •  
  • this is for all the preggo ladies
  • i have a friend who had with his 14 year old girlfriend when he was 17 she might have gotten pregnant
  • what do you think of women with
  • is it mine if it 039 s in my yard
  • pregnancy symptoms help
  • tattoo 039 s what do women really think about guy 039 s with tattoo 039 s
  • survey should ll cool j be known only as ll j now that he is selling clothes for sears
  • why are you supposed to wait 6 weeks after having a baby to have again
  • any traditional english or modern rabbit or hare recipes
  • if obama won for president how would you react
  • what do we do
  • creative baked goods for a birthday party
  • please help me with some project ideas thanks
  • i cant find how to make an avater
  •  Homepage | Add to favorites | Contact us | Exchange links | LOGIN | Site map | 
    Copyright© 2008 nnkl.com        Site made:CFZ