473,406 Members | 2,894 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,406 software developers and data experts.

I added Date$ to a query field and am getting shaky results

MLH
Sometimes it works and sometimes it crashes.

If I want "Today is " & Date$ & "." to appear
in a query field, why might it work sometimes
and not others?

Would I be better to call a FN? Say, something
like "Today is " & GetDateString() & "." ???
If 'Yes' - why is that?
Jun 27 '08 #1
8 1796
MLH
I substituted Format$(Now(),"Long Date") and
that seems to run OK. But so did Date$ at first.
Then it later puked when executed in my live
data copy. C any reason why this approach
would ever become an issue?
Jun 27 '08 #2
MLH <CR**@NorthState.netwrote in news:7laa045ke412afe3mn516js3sl9dktcde1@
4ax.com:
Sometimes it works and sometimes it crashes.

If I want "Today is " & Date$ & "." to appear
in a query field, why might it work sometimes
and not others?
It's probably got itself confused with "What sign are you?"

Jun 27 '08 #3
On Tue, 15 Apr 2008 18:25:11 -0400, MLH <CR**@NorthState.netwrote:
>Sometimes it works and sometimes it crashes.

If I want "Today is " & Date$ & "." to appear
in a query field, why might it work sometimes
and not others?

Would I be better to call a FN? Say, something
like "Today is " & GetDateString() & "." ???
If 'Yes' - why is that?
Date$ and Now() are two rather different functions, and both follow
different paths to get the system date and time settings back to
whatever is calling them.

Date$ doesn't "honor" the Windows date and time format settings for
example, while both the Date() and Now() functions will. Surprisingly
however, I've personally found that Now() is faster then Date$.
(Indeed, even Format$(Now(),"mm/dd/yyyy") is faster then Date$. Your
milage however, may vary.)

The Date$ and Now() functions also return 2 different types of data.
Date$ returns a string, Now() returns a date. (Well, ok, it's a
Variant sub-type Date, but it's close enough to a date that Access
won't appear to care, while it will care if it has to handle a String
as if it was a date, for sorting, grouping, etc.)

As for using a module level function to get the date rather then the
Now() function (or Date() function for that matter), I've only had to
result to that when I've needed further processing on the information,
or in cases where I needed a date that was "universal" across many PCs
in multiple locations. For example, when I needed a date (and/or
time) that was going to be the same everywhere across an organization,
regardless of where the user was, or despite what they did to their
computer's clock.
--
Please Post Any Replies To This Message Back To the Newsgroup.
There are "Lurkers" around who can benefit by our exchange!
Jun 27 '08 #4
On Apr 15, 6:32*pm, MLH <C...@NorthState.netwrote:
I substituted Format$(Now(),"Long Date") and
that seems to run OK. But so did Date$ at first.
Then it later puked when executed in my live
data copy. C any reason why this approach
would ever become an issue?
A reason could be that there is some other object or variable named
Date; I suggest that your try qualifying Date$ as VBA.Date$. If you
want the result to be formatted as per Regional Settings you could use
VBA.CDate(VBA.Date$).
I'd probably use Format$(VBA.CDate(VBA.Date$), "mmmm\ d\,\ yyyy"); I
can't think of any situation where this would fail.
Jun 27 '08 #5
On Apr 15, 6:52*pm, lyle fairfield <lylef...@yah00.cawrote:
MLH <C...@NorthState.netwrote in news:7laa045ke412afe3mn516js3sl9dktcde1@
4ax.com:
Sometimes it works and sometimes it crashes.
If I want "Today is " & Date$ & "." to appear
in a query field, why might it work sometimes
and not others?

It's probably got itself confused with "What sign are you?"
Nice line Lyle! Look out for 'negative' answers :-). We're just too
hyperliteral. It's an occupational hazard. Here's a shot in the
dark. I think the part about confusion might be on the right track.
Suppose the OP had Office 97 installed, then upgraded to a non-
Professional (i.e., sans Access 2K3) Office 2K3, or maybe even
installed Office 2K3 Professional and went back to A97 for some
reason. It seems that programs such as Excel and Access, which share
a lot of the same functions should be on the same page, VBA librarily
speaking. No references would show up as Missing, but there might be
problems in Access when the OP tries to use those shared functions
because of the VBA library mismatch, the current VBA library being the
one from Office 2K3. If your VBA qualifier doesn't solve the problem
perhaps the OP should look into the possibility of such a mismatch.
IIRC, and I'm not positive about this, there are some situations where
A97 can run along with, say Office 2K3, and others where it can't
unless the functions are called within a Visual Basic Editor
environment or possibly just within a true module. Finding a solution
possibly depends on whether or not the Office install process deleted
the old VBA file, perhaps VBEEXT1.OLB, or not. Selecting a different
install directory for each version of Office on a single computer
should have kept the old VBA file intact. If so, clicking 'Browse' in
References to add a different type library reference as 'Visual Basic
For Applications' pointing to the old VBA file might solve the problem
in Access without breaking VBA in the rest of Office.

James A. Fortune
CD********@FortuneJames.com
Jun 27 '08 #6
On Apr 15, 11:01*pm, CDMAPos...@fortunejames.com wrote:
On Apr 15, 6:52*pm, lyle fairfield <lylef...@yah00.cawrote:
It's probably got itself confused with "What sign are you?"

Nice line Lyle! *Look out for 'negative' answers :-). *We're just too
hyperliteral. *It's an occupational hazard. *Here's a shot in the
dark. *I think the part about confusion might be on the right track.
:-)

A spry 70-year-old software developer decided to marry a 42-year-old
redhead. He explained to her that because he wakes easily at the
slightest movement they would always have to sleep in separate rooms
-- he could easily afford that arrangement for their honeymoon suite
-- but that they could still enjoy the privileges of marriage before
settling down for the night. On their wedding night he told her that
he'd take a little nap and asked her to be ready to consummate their
marriage. A little later she heard a few taps on her door. They
consummated their marriage and the software developer went back to his
room. A little later, he knocked on the door again. Delighted, his
new bride had no objection to celebrating their marriage again.
Afterward, he went back to his room again. A little while later,
there were more taps at the door. Astonished, she exclaimed, "Three
times in one night for a 70-year-old man!" His eyes widened as he
said, "You mean I've been here before!"

James A. Fortune
CD********@FortuneJames.com
Jun 27 '08 #7
On Apr 15, 11:01*pm, CDMAPos...@fortunejames.com wrote:
If your VBA qualifier doesn't solve the problem
perhaps the OP should look into the possibility of such a mismatch.
If your software is designed to work on multiple versions of Access
you might be able to get away with unchecking the DAO 3.5 reference
placed there by the Access 97 install, then checking the DAO 3.6
reference left there by an earlier install of a later Office. YMMV.

James A. Fortune
CD********@FortuneJames.com

Jun 27 '08 #8

"MLH" <CR**@NorthState.netwrote in message
news:05********************************@4ax.com...
>I substituted Format$(Now(),"Long Date") and
that seems to run OK. But so did Date$ at first.
Then it later puked when executed in my live
data copy. C any reason why this approach
would ever become an issue?
Date is an Access reserved word (the name of a built-in function) and there
often are some problems in using reserved words for other purposes. The $
implies text, by the way, and date/time fields and variables are not text.

Larry Linson
Microsoft Office Access MVP
Jun 27 '08 #9

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

Similar topics

16
by: jason | last post by:
I'm tearing out my hair here: ACCESS 2000: When I attempt to overwrite a date in my date field with a new user selected valid date eg: 05/23/99 my date field changes to the TIME I updated the...
7
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
by: Bayla Frankl | last post by:
Hi all, I am a little stumped. I have a query I am trying to run to retrieve the last Progress Note record from the database for the current patient so that the therapists can see the last note...
2
by: BlackFireNova | last post by:
I have an Access 2003 mdb which contains software records. I need to sort on a particular type of software, and then identify and count how many copies there are per each group of that type...
1
by: Ken | last post by:
I wrote a function to use in queries that takes a date and adds or subtracts a certain length time and then returns the new value. There are times when my function needs to return Null values. ...
12
by: Steve Elliott | last post by:
I have a query set up to gather together data between two specified dates. Shown in the query column as: Between #24/09/2004# And #01/10/2004# Is it possible to enter several different date...
2
by: Billy | last post by:
This string is supposed to provide all records from an MDB database that match the courier and date specified in the query. I Response.Write the query and I get a date as 1/27/2007. The date...
7
by: Katherine | last post by:
I'm trying to filter the records on the mainform (MailingList) of my database using a field contained in a subform (Donations). I was basing my code off Allen Browne's Access Tips page (here:...
8
by: Dr Al | last post by:
I have a table with four date fields, some of which may not be filled in based on our data entry needs. I have a criteria set as <date()-180 which is supposed to pull dates older than 180 days ago....
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
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
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
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
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
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,...

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.