473,398 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Combine Date/Time fields

11
I am working with a table that lists dates and corresponding times in separate fields. For purposes of building a query to calculate elapsed time I would like to combine a [Short Date format] field with a [Long Time format] field ending up with a new field [General Date format]... Is it Possible?
Aug 15 '07 #1
14 15341
Rabbit
12,516 Expert Mod 8TB
You'll want to take a look at the CDate function.
Aug 15 '07 #2
missinglinq
3,532 Expert 2GB
I'm not sure you need to use CDate() Rabbit. How Access handles these date things is so quirky, but simply doing

YourNewField = YourShortDate & " " & YourLongTime

seems towork just fine. You can then use the results in Date oriented functions, such as DateAdd and DateDiff, without problems.

Welcome to TheScripts, New Poster!

Linq ;0)>
Aug 16 '07 #3
TIonLI
11
Thanx Rabbit and Linq. It worked great. dateDiff was the icing on the cake!
Aug 16 '07 #4
TIonLI
11
I'm not sure you need to use CDate() Rabbit. How Access handles these date things is so quirky, but simply doing

YourNewField = YourShortDate & " " & YourLongTime

seems towork just fine. You can then use the results in Date oriented functions, such as DateAdd and DateDiff, without problems.

Welcome to TheScripts, New Poster!

Linq ;0)>
Linq,

I'm having a problem trying to limit the results of the DateDiff expression. I would like to return only positive values with a cap at 12. I tried:
Between 0.1 And 12.1
and
>0.1 And <12.1
In each case I get a pop-up looking for a Parameter Value for Expr2 (which is the code that adds a date with the corresponding time per your earlier response).
Aug 16 '07 #5
missinglinq
3,532 Expert 2GB
Show us your code so far.

Linq ;0)>
Aug 16 '07 #6
TIonLI
11
Show us your code so far.

Linq ;0)>
To combine date/time:
Expr2: [ARREST-DATE] & " " & [ARREST-TIME]
and
Expr3: [ENTRY-DATE] & " " & [ENTRY-TIME]
To calculate elapsed time:
Expr4: (DateDiff("n",[Expr2],[Expr3]))/60

The DB currently has about 185000 records. I want to limit returns for Expr4 to only those that are 12 hours or less, AND I don't want to return negative numbers (There are a few bad data entries so I tried to prevent them from being used by using <"Expr3" as a criteria for Exp2, but it only works if the dates don't fit the criteria. On records where the date is the same and the hours are in question, <"Expr3" doesn't seem to make a difference.)

Thanx for all the help.
Aug 16 '07 #7
missinglinq
3,532 Expert 2GB
OK, where's the code you're using to try to limit the returned records to >.1 and < 12.1? And where are you putting this? In a query, or where? I'll probably be gone the rest of the evening, but if I'm not here someone else will come along.
Aug 16 '07 #8
TIonLI
11
OK, where's the code you're using to try to limit the returned records to >.1 and < 12.1? And where are you putting this? In a query, or where? I'll probably be gone the rest of the evening, but if I'm not here someone else will come along.
The Code I tried was:
Between 0.1 And 12.1
and
>0.1 And <12.1
Both as a criteria for Expr4 in a query.
Aug 17 '07 #9
missinglinq
3,532 Expert 2GB
OK, where's the code you're using to try to limit the returned records to >.1 and < 12.1? And where are you putting this? In a query, or where?
You said that before; we need to see the actual code, not just a snippet! And where are you placing this code?

Linq ;0)>
Aug 17 '07 #10
You may want to try building a new query with just the criteria for .1< And >12.1 keeping the date and time separate, and then building a new query off of that one making your concatenated field in the second query this way access does not get confused with the criteria referring to date or time. Sounds strange but I had to do similar.
Aug 17 '07 #11
TIonLI
11
You may want to try building a new query with just the criteria for .1< And >12.1 keeping the date and time separate, and then building a new query off of that one making your concatenated field in the second query this way access does not get confused with the criteria referring to date or time. Sounds strange but I had to do similar.
I'm scratching my head, but it worked... Thanx
Aug 17 '07 #12
TIonLI
11
You said that before; we need to see the actual code, not just a snippet! And where are you placing this code?

Linq ;0)>
Linq,

Just to help me provide the proper info when asking a question in the future, I'm confused as to what code you were asking me to provide other than what I gave you. "Between 0.1 And 12.1" was the only code I entered in the criteria field of the query. In the end it ended up being correct but only after I built a new query that pulled in the results of Expr4 from the original query. Is there something else I should have provided?

Also, Thanx again to you and all others for your assistance... and patience.
Aug 17 '07 #13
I have a mail merge where I had to do the same thing because I could not have any criteria in the query that it was using. The sad part is that was just the iceing on the cake glad it worked for you good luck.
Aug 17 '07 #14
missinglinq
3,532 Expert 2GB
Glad it worked for you, TIonLI!
Between 0.1 And 12.1" was the only code I entered in the criteria field of the query
That's what was missing! You didn't say "I entered in the criteria field of the query" in your posts! Didn't know whether you were doing this in code, in a SQL staatement or, as was the case here, in the Criteria Field in the Query Grid! The single biggest thing to remember, as NeoPa, the Forum Leader here, reminds everyone, is that the memebers here can't see what you see when you look at your database! We only know what you tell us.

It's great that you care enough to ask! I look forward to working with you again!

Linq ;0)>
Aug 17 '07 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Steve Jorgensen | last post by:
Hi all, I'm working on the schema for a database that must represent data about stock & bond funds over time. My connundrum is that, for any of several dimension fields, including the fund name...
1
by: Chris Lutka | last post by:
I've been racking my brains all day over this. And I'm not the best at SQL either. I need a query that will produce the following results:...
5
by: Jamie Pittman via AccessMonster.com | last post by:
I have two tables with 5000 entries on them. One is based for regular time with several variables example (employee name, date,time in and out, code, customer, building) I have another table that...
1
by: rdraider | last post by:
Hi all, We have an app that uses SQL 2000. I am trying to track when a code field (selcode) is changed on an order which then causes a status field (status) to change. I tried a trigger but...
6
by: Luvin lunch | last post by:
Hi, I'm new to access and am very wary of dates as I have limited experience in their manipulation and I know if they're not done properly things can turn ugly quickly. I would like to use a...
2
by: drurjen | last post by:
Good morning. I am importing an XLS file into one of my tables. The fields are: Date Id Time IO 12/22/2006 2 12:48:45 PM 9 12/22/2006 16 5:40:55 AM 1 12/22/2006 16 12:03:59 PM 2 ...
1
by: bluereign | last post by:
Thank you for your assistance. I am a novice looking to JOIN and append or combine records from 2 current Tables into 2 new Tables named below. I have been able to JOIN Tables with the script...
1
by: csolomon | last post by:
Hello: I am using two queries to get one result set. The issue is, I return no data when I combine them into one query. I have listed both queries, as well as the 3rd query that shows them...
4
by: ghjk | last post by:
In my php application user should enter date and time separately. But i want to combine them to compare with database value. How can i do that? user input Date:2008-03-25 User input time:11:30 Eg;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.