473,508 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Evaluate Date/Time Field for Existence of Time

I have some data that I need to run date diffs on. The catch is that
for some of this data, there is a date value in one of the fields,
with no time. It might look like this:

ROW DT1 DT2
1 1/1/08 8:00 AM 1/1/08 10:00 AM
2 1/2/08 9:00 AM 1/2/2008
3 1/3/08 10:00 AM 1/3/08 12:00 PM
4 1/4/2008 1/4/08 1:00 PM
5 1/5/08 1:00 PM 1/5/08 2:00 PM
So row one can calculate at 2 hours. Row 2, cannot (I have another
column to take over when this is the case). Row 3 is good, 4, I need
to override. etc.

Can anyone please help me on how I stipulate this condition in an
access query?
Oct 22 '08 #1
2 3650
no****@thankyou.com wrote:
I have some data that I need to run date diffs on. The catch is that
for some of this data, there is a date value in one of the fields,
with no time. It might look like this:

ROW DT1 DT2
1 1/1/08 8:00 AM 1/1/08 10:00 AM
2 1/2/08 9:00 AM 1/2/2008
3 1/3/08 10:00 AM 1/3/08 12:00 PM
4 1/4/2008 1/4/08 1:00 PM
5 1/5/08 1:00 PM 1/5/08 2:00 PM
So row one can calculate at 2 hours. Row 2, cannot (I have another
column to take over when this is the case). Row 3 is good, 4, I need
to override. etc.

Can anyone please help me on how I stipulate this condition in an
access query?
d = date()
n = now()
? timevalue(d)
12:00:00 AM
? timevalue(n)
11:26:00 AM
? format(d,"mm/dd/yyyy hh:nn:ss")
10/22/2008 00:00:00
? format(n,"mm/dd/yyyy hh:nn:ss")
10/22/2008 11:26:00 AM
? format(d,"general date")
10/22/2008
? format(n,"general Date")
10/22/2008 11:26:00 AM
A Now() value returns date and time. Date() returns date and the time
is always 00:00:00am. I suppose you could check for the existance of a
: for those with/without a time using instr()
? instr(format(date(),"general Date"),":") = 0
True
? instr(format(now(),"general Date"),":") = 0
False

So you could create a column
Override : IIF(instr(format(date(),"general Date"),":") = 0 or _
instr(format(now(),"general Date"),":") = 0, _
"OverRide","OK:)
that displays OK or Override depending if both dates have a time.

Oct 22 '08 #2
Thanks! That should do it!
Oct 23 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
682716
by: vnl | last post by:
I'm trying to run a SQL query but can't find any records when trying to select a certain date. Here's the sql: SELECT field 1, field2, date_and_time, FROM table1 WHERE date_and_time =...
5
1867
by: Steve | last post by:
Hello, I've been a PHP programmer for a number of years and have just started to learn JS. My Employer (a water analysis lab) wants what should be a very simple .js written that basically takes...
5
4277
by: Javier | last post by:
I have a field type Date/Time that automatically defaults to Now(). I'm having a problem writing a query that will retrieve all the records for a specific date the user to enters when prompted. I...
5
3788
by: Kermit Piper | last post by:
Hello, I am comparing two date values, one from a database and one that has been converted from a hard-coded string into an actual Date type. So far so good. The problem I'm having is that one...
1
1833
by: Graham Feeley | last post by:
I have a date field named rcdate it is a general date eg: 12/08/2006 3:30:00 PM 12/08/2006 3:00:00 PM I used to update another empty field named rdate with the with using in a update query "...
6
12524
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...
11
2715
by: altreed | last post by:
Hi, I am new to ASP, HTML and iis. I have my asp code working so that I can retrieve my desired record from the database. I can place the data on the screen in table form. All works fine. ...
3
12864
by: colleen1980 | last post by:
Hi: Data in my table is in that format. How to i separate date with time. 11/9/2006 10:10:46 AM Thank You.
7
2120
Wing
by: Wing | last post by:
I was wondering if it is possible to evaluate a variable to determine if the variable is a control on the current or other form? Here is what I am currently looking at. I have two date fields that...
0
7229
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
7333
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7398
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...
1
7061
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
7502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5637
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3194
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1566
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
428
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.