Querying dates & times

I am struggling with running a query where the field is both a date and a 
time.  i.e.  01/25/2010 3:40 pm.  When running the query, it doesn't see 
anything.  After entering the query criteria, it only shows up as 
#01/25/2010# and no data selected... Any suggestions?

Thx, D
0
Utf
1/25/2010 10:10:01 PM
access.queries 6343 articles. 1 followers. Follow

6 Replies
609 Views

Similar Articles

[PageSpeed] 31

Can you tell us how you would like this to work? Do you want to ignore the 
time portion of the value or is the time significant to the criteria?

-- 
Duane Hookom
Microsoft Access MVP


"Digi777" wrote:

> I am struggling with running a query where the field is both a date and a 
> time.  i.e.  01/25/2010 3:40 pm.  When running the query, it doesn't see 
> anything.  After entering the query criteria, it only shows up as 
> #01/25/2010# and no data selected... Any suggestions?
> 
> Thx, D
0
Utf
1/25/2010 10:31:01 PM
Hi... the time is very important.  I am trying to find the first timestamp of 
the day and the last timestamp of the day....

I really appreciate your responding! 

David.

"Duane Hookom" wrote:

> Can you tell us how you would like this to work? Do you want to ignore the 
> time portion of the value or is the time significant to the criteria?
> 
> -- 
> Duane Hookom
> Microsoft Access MVP
> 
> 
> "Digi777" wrote:
> 
> > I am struggling with running a query where the field is both a date and a 
> > time.  i.e.  01/25/2010 3:40 pm.  When running the query, it doesn't see 
> > anything.  After entering the query criteria, it only shows up as 
> > #01/25/2010# and no data selected... Any suggestions?
> > 
> > Thx, D
0
Utf
1/25/2010 10:36:06 PM
SELECT DateValue(FieldDateTime) as JustDate
, Min(FieldDateTime) as Earliest
, Max(FieldDateTime) as Latest
FROM SomeTable
GROUP BY DateValue(FieldDateTime)

If you want to restrict that to a specific date or date range add a WHERE 
clause.  For instance to get all the dates in January of 2009 use something 
like the following.

SELECT DateValue(FieldDateTime) as JustDate
, Min(FieldDateTime) as Earliest
, Max(FieldDateTime) as Latest
FROM SomeTable
WHERE FieldDateTime >= #2009-01-01# and FieldDateTime<#2009-02-01#
GROUP BY DateValue(FieldDateTime)

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Digi777 wrote:
> Hi... the time is very important.  I am trying to find the first timestamp of 
> the day and the last timestamp of the day....
> 
> I really appreciate your responding! 
> 
> David.
> 
> "Duane Hookom" wrote:
> 
>> Can you tell us how you would like this to work? Do you want to ignore the 
>> time portion of the value or is the time significant to the criteria?
>>
>> -- 
>> Duane Hookom
>> Microsoft Access MVP
>>
>>
>> "Digi777" wrote:
>>
>>> I am struggling with running a query where the field is both a date and a 
>>> time.  i.e.  01/25/2010 3:40 pm.  When running the query, it doesn't see 
>>> anything.  After entering the query criteria, it only shows up as 
>>> #01/25/2010# and no data selected... Any suggestions?
>>>
>>> Thx, D
0
John
1/25/2010 10:45:08 PM
Duane,

Any way to do this with access commands?


"Duane Hookom" wrote:

> Can you tell us how you would like this to work? Do you want to ignore the 
> time portion of the value or is the time significant to the criteria?
> 
> -- 
> Duane Hookom
> Microsoft Access MVP
> 
> 
> "Digi777" wrote:
> 
> > I am struggling with running a query where the field is both a date and a 
> > time.  i.e.  01/25/2010 3:40 pm.  When running the query, it doesn't see 
> > anything.  After entering the query criteria, it only shows up as 
> > #01/25/2010# and no data selected... Any suggestions?
> > 
> > Thx, D
0
Utf
1/26/2010 1:28:01 PM
On Tue, 26 Jan 2010 05:28:01 -0800, Digi777 <digi777@hotmail.com> wrote:

>Any way to do this with access commands?

ummm...

other than the Access commands which John Spencer suggested?

You'll need a Query. A Query consists of SQL. (The query grid is nothing but a
tool to make it easier to build SQL). That SQL can contain calls to builtin
Access functions such as DateValue.

In case you didn't see it here's John's reply, repeated:


SELECT DateValue(FieldDateTime) as JustDate
, Min(FieldDateTime) as Earliest
, Max(FieldDateTime) as Latest
FROM SomeTable
GROUP BY DateValue(FieldDateTime)

If you want to restrict that to a specific date or date range add a WHERE 
clause.  For instance to get all the dates in January of 2009 use something 
like the following.

SELECT DateValue(FieldDateTime) as JustDate
, Min(FieldDateTime) as Earliest
, Max(FieldDateTime) as Latest
FROM SomeTable
WHERE FieldDateTime >= #2009-01-01# and FieldDateTime<#2009-02-01#
GROUP BY DateValue(FieldDateTime)
-- 

             John W. Vinson [MVP]
0
John
1/26/2010 5:39:33 PM
I asked two questions and you replied with no answers and a vague question.

-- 
Duane Hookom
Microsoft Access MVP


"Digi777" wrote:

> Duane,
> 
> Any way to do this with access commands?
> 
> 
> "Duane Hookom" wrote:
> 
> > Can you tell us how you would like this to work? Do you want to ignore the 
> > time portion of the value or is the time significant to the criteria?
> > 
> > -- 
> > Duane Hookom
> > Microsoft Access MVP
> > 
> > 
> > "Digi777" wrote:
> > 
> > > I am struggling with running a query where the field is both a date and a 
> > > time.  i.e.  01/25/2010 3:40 pm.  When running the query, it doesn't see 
> > > anything.  After entering the query criteria, it only shows up as 
> > > #01/25/2010# and no data selected... Any suggestions?
> > > 
> > > Thx, D
0
Utf
1/26/2010 6:20:03 PM
Reply:

Similar Artilces:

Will Excel tell me when a date is near?
Hi all, I was just wondering if Excel is capable of alerting its user when date is near or when it has arrived. I know that alot of calande programs will do this however those programs wont keep track of th other information I need. I am trying to keep a list of my buisness' clients and when thie insurance expires. I would like a pop up message or some other type o alert when a date comes near. I dont know if Excel can even do this. Any suggestions will help. Thank -- Message posted from http://www.ExcelForum.com Here's a technique that I discovered a few weeks ago, and I am ...

Timer for Queries?
Does anyone know of a macro or add-on that I could use as a simple timer for queries? I don't like to use the CPU time in the Task Manager because of it's inaccuracy when not receiving full CPU usage. THanks for any suggestions -- cmungs Exactly what are you trying to accomplish? Are you trying to cause a query to run automatically every so often? If so, you will need to use the timer event on a form to do that. -- Lynn Trapp Microsoft MVP (Access) www.ltcomputerdesigns.com "cmungs" <cmungs@discussions.microsoft.com> wrote in message news:88EC7019-045F-4EF...

How to Calculate the Date and The Number
Guys, Please help me on how to do the below calculations. Date (YYDDMM) 080131 = it goes like this 8+1+3+1 = 13 is the answer Text 1000888 = it goes like this 1+8+8+8= 25 is the answer Thanks This function will do what you seek: Private Function GetSumOfDigits(varData As Variant) As Long Dim lngPos As Long, lngSum As Long lngSum = 0 If IsNull(varData) = False Then For lngPos = 1 To Len(varData) lngSum = lngSum + Val(Mid(varData, lngPos, 1)) Next lngPos End If GetSumOfDigits = lngSum End Function -- Ken Snell <M...

Erratic results from query criteria
I am getting different results from running the same query with the same selections. One moment it is all behaving as expected, the next it has gone haywire. (I have done what appears to me to be EXACTLY what I have done in another database, where it works perfectly every single time.) In a query I have, amongst others, the following fields: Category SubCategory Company I want to be able to select any OR ALL of the relevant fields. I have the following criteria: Like "*"&[Type Category otherwise leave blank for ALL]&"*" Like "*"&a...

Update Query ?
Is there a way to 1) Assign events when adding in data thru an update query for example if you append a bunch of data into a table could you then do some kind of an update query to say if there is an initial event and no others tag this one Renewal 1 etc.. the only real data you have to go on would be Customer A and the total amt .. the event, renewal event and the delta would all need to be added in example: Say Customer A comes in with an initial deal then Customer A renews their deal So, the data would look like when you're done.: Year Custo...

Sort by Hebrew Date
Does anyone know if (and how) Excel's sort by date function can be used to sort by Hebrew date rather than English Date? Excel can handle the year, but the months and days do not map directly. If you format the dates as integers in the form yyyymmdd, always using 2 digits for the month and day, the standard numerical sort might work. -- Gary's Student "Desperate Dan" wrote: > Does anyone know if (and how) Excel's sort by date function can be used to > sort by Hebrew date rather than English Date? > ...

design query match anywhere?
In the design query I want to match the letters "ABC" anywhere in the column 'description'. I could not get instr to work by using: InStr(description, "ABC")) > 0 How else can I match ABC (upper and lowercase) to anywhere in my 'description' column? Thanks! Are you saying you put that InStr bit as a criteria under your Description field in the query designer? Try putting Like "*ABC*" as the criteria instead. Alternatively, you could add a computed field to the query InStr([Description, "ABC") and then put >0 as the ...

Unexpected Error- Running Advance Find Query
I am getting a message that says "Unexpected Error An Error has occurred" when I am running an advanced find query on two custom entities. It seems to be when I have certain custom fields included in my view that the query errors out. Any help on this would be greatly appreciated. Thanks so much. Just wanted to add that I seem to get errors when there is a 0.00 amount in these fields... "TJ" wrote: > I am getting a message that says "Unexpected Error An Error has occurred" > when I am running an advanced find query on two custom entities. It se...

automatic date
Is there anyway that a specific date shall be entered automatically for example the computer shall search in the excel table if there is already a date as the 10 of the current month if not it shall input the date in a date field a cell each 10 th of the month after it past or on it ...

Time calculations for Scheduled vs Actual Employee Time and Wages 11-29-09
I am THRYING to make a simple schedule worksheet for a manger to use to calculate the time he schedules an employee to clock in and out and what it will cost him in regards to his allocated budget and then to be able to compare it after the job is completed. BUT time calculations have thrown me for loop and I am stuck for hours on trying to calculate time fields. PLEASE DEAR GOD can someone help me. Below is a simple example of my worksheet. A2 (Time IN) = 1:00 PM A3 (Time OUT) = 5:00 PM A4 (Time Worked) = 4:00 (h:mm format) Formula A3...

pass through query
If a combobox is populated by a pass-through query, does it requery every time the form is closed and reopened? Thanks, Sam Yes. John Spencer Access MVP 2002-2005, 2007-2010 The Hilltop Institute University of Maryland Baltimore County Sam wrote: > If a combobox is populated by a pass-through query, does it requery every > time the form is closed and reopened? > Thanks, > Sam ...

a count field in a query?
Hello, I have a query in which I would like to create a field which increments by 1 for each record selected, so if there are 10 records selected by the query, this column would show numbers 1 to 10. Ideally I would like to have some text in front of each number, say invoice1, invoice2 etc. From a previous posting I realise that this is frowned upon but it would be the simplest solution for my problem! How can I do this? Thanks Geoff On Mon, 03 Dec 2007 08:54:00 +0000, Geoff Cox <<>> wrote: >Hello, > >I have a query in which I would like to create a field which >...

Excel date
How can I auto. populate the current date in an Excel spreadsheet. In Word, I can begin to type the current date and Word suggests the current date. Can this be done in Excel? Ward, Use CTRL+; -- Cordially, Chip Pearson Microsoft MVP - Excel www.cpearson.com chip@cpearson.com "Ward Harriman" <harrimw@wamc.com> wrote in message news:026701c377bc$7c6581d0$a101280a@phx.gbl... > How can I auto. populate the current date in an Excel > spreadsheet. In Word, I can begin to type the current > date and Word suggests the current date. Can this be done > in Exc...

Sort by date field
I am using Windows XP and Access 2000. I have two tables Tbl-TrainingWaiting and Tbl-TrainingSchedule. I have a form called Frm-TrainingWaiting which has the table Tbl-TrainingWaiting as the Record Source. I use =TRACourse1.Column(1) in the Control Source of a text box to display the date held in the Tbl-TrainingSchedule table. I am trying to make the form Frm-TrainingWaiting sort on the date field. Can this be done? Thanks you in advance for any help. Richard "Richard" <Richard@discussions.microsoft.com> wrote in message news:560D5293-F2B4-4FA9-B...

How do I point out a specific date on a line graph in Excel?
Hello. I have a few series on a line graph in excel. I want to point out specific dates without having to manually add a arrow, textbox, or line. Ideally, I would like to be able to have a vertical line on a specific date that would indicate before and after. Thanks. "Keylay31" <Keylay31@discussions.microsoft.com> wrote in message news:6278F29F-3391-4B89-AEE5-8E7666423650@microsoft.com... > Hello. I have a few series on a line graph in excel. I want to point out > specific dates without having to manually add a arrow, textbox, or line. > Ideally, I would like to ...

Saving Username and Pass with Web Queries
I am pulling data from a website that requires you to provide a usernam and password everytime you visit the site. Excel has cachin capabilities, but everytime you close excel and try and open up th spreadsheet again, it can't login. What is the fix for this? Thanks, Hend -- Message posted from http://www.ExcelForum.com Bump! --- Message posted from http://www.ExcelForum.com/ ...

Birthday query for many children in one record
I have a database for the church, it has one main flat table only. Each record for the parents have field for child1 name, child1birthday, child2 name, child2birthday, child3 name, child3birthday - up to 5 children. I am having difficulty trying to get a report to list the birthdays of the children like this parent name, child 1 name, child 1 birthday month etc. so you get something like this:- Parent John Smith, child Mary Smith January 3 Parent Fred Jones, child Bert Jones March 4 Parent John Smith, child Jane Smith March 6 Parent Harry Brown, child Jane Brown March 6 Parent Bert Taylor,...

Unresponsive Query Wizard
Hi there, I have an Excel 2003 user who is using a spreadsheet that pulls data from our SQL server. When he opens it and refreshes the data it is fine, it pulls the current data, but when he tries to edit the query, the Query Wizard does not appear, he can see it on the task bar, but when he switches focus using task manager everything is greyed out and nothing works. I have tested the file from my computer and it is fine, which suggests a problem with his machine or installation. Does anyone have any ideas? Cheers, Steve Dooza wrote: > Hi there, > I have an Excel 2003 user who...

Another simple query
Dear all, I have a table that contains first names and last names in different fields. Is there any way to write a query that will give as a result the first name and last name in the same field? I hope this makes sense. Thanks in advance! SELECT [last_name_field] & ", " & [first_name_field] AS whole_name FROM [your_name_table] Change the field and table names to whatever your actual fields and tables are. Cheers, Jason Lepack On Apr 23, 9:47 am, Homer <peter.a.r...@googlemail.com> wrote: > Dear all, > > I have a table that contains first names an...

Query query
I am trying to create a new field in which it shows the sum total of 10 fields (Charge Time, Charge Time 2, Charge Time 3, etc.); what is the easiest way to do this? -- Joe NewFieldName: [Charge Time] + [Charge Time 2] + [Charge Time 3] .... etc -- Good Luck BS"D "joet5402" wrote: > I am trying to create a new field in which it shows the sum total of 10 > fields (Charge Time, Charge Time 2, Charge Time 3, etc.); what is the easiest > way to do this? > -- > Joe I tried this, and it doesn't work. Is there something I'm forgetting? -- Joe ...

Earliest Date via LookUp?
is it possible to select the earliest date from a list via vlookup?What should my formula look like? Many Thanks for your assistanc -- Message posted from http://www.ExcelForum.com I guess you would have to sort the table with your variable and date ascending first and then use the vlookup function. ie =VLOOKUP("A",A:B,2,0). I would be tempted to automate the sort (possibly everytime you enter the formulae sheet). =MIN(DateRange) "Bush Kangaroo >" <<Bush.Kangaroo.15ivfe@excelforum-nospam.com> wrote in message news:Bush.Kangaroo.15ivfe@excelforum-nospam....

group by query trouble
I'm trying to run a query that counts the number of people with hemoglobin of type SS, type SC, and then all others. There are about 12 different kinds of types. Basically I want a count for SS, a count for SC, and then a count that totals all the others into one count. Hopefully that makes sense. I'm using group by for the SS and SC which works great, but I'm not sure how to tell it to add up the others. I'm not a big fan of nested IIf statements, but this should work after you put in the proper field and table names: SELECT IIf([Hemoglobin]="SC","SC&...

To Query or not to Query??
Hello all - I'm a newbe to Access but have made great progress. I'm using Acess 2003. The db is up and running prefectly. Now I need to tackle the reporting. I have seen posts about reports and queries and am a little confused. Do I need to create a query to run my reports off of? I have a tabbed subform in the main form. There are seven tabs breaking up all the services we provide. Like "Promo Items", "Leads", "Client Printed Material","Internal Print Material" and so on. The main form has the User, Branch and Marketing Rep. I need to...

Do I have to enter a start AND end date for a task in Outlook?
I am getting a conflict when trying to sync between Outllook 2003 and Blackberry Desktop Manager. Error msg talks of a task having a negative duration and to check the start/end dates/times. when setting the dates, use the start date button. One click on a dtae there will enter the same data for start date and due date. If you want to have a period of time between the dates, use the start date button and wipe a period with your mouse on the little date navigator. -- Regards Judy Gleeson MVP Outlook www.judygleeson.com www.deskdoctors.com Are you sick of bad email practice? Get a c...

Dynamic Query
Hi! I am trying to dynamically modify my pass-through query containing a procedure call with 2 parameters. When I run my access app, I get this error: "Object or provider is not capable of performing reuqested operation." Below is my access code: Dim varItem As Variant Dim strSQL As String Dim cat As ADOX.Catalog Dim cmd As ADODB.Command Dim strMyDate As String, dtMyDate As Date dtMyDate = CDate([Forms]![ySalesHistory]![Start Date]) strMyDate = Format(dtMyDate, "yyyymmdd") strSQL = "procCustomerSalesandPayments '" & s...