473,386 Members | 1,815 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,386 software developers and data experts.

Removing "seconds" off General Date on a report.

Hello,
I'm new to Access and DB's in general. I've taken over some light
duty support for a lab information system we use in house. Most of our
dates are reported as "10/31/2006 12:30:00 PM" (With seconds listed in
the report field).

However, nobody wants to see the seconds. So I tried to format it
=Format(DateCollected, "mm/dd/yy hh:nn AM/PM").

Works great, right? Well.. yeah for the most part. However if we
have something come in from a client and they list a date with no time,
then the report spits out "10/30/06 12:00 AM" since the date is empty,
the formatting assumes it's 0 Hour I guess.
So in short, the formatting works unless we have no time recorded for
the particular item we are testing.

Is there a way to get the format to ignore the hh:nn AM/PM section if
no time exists? Keep in mind these are when generating reports that go
back to the client... so they must be accurate.

Thank you, I hope I've made it clear what I'm looking for.

-Ryan

Oct 31 '06 #1
8 4415
Ryan
Try this. At one point you say the date is empty But I think you meant there
is no time, yes?

= IIF( Instr(Format(DateCollected, "mm/dd/yy hh:nn AM/PM"),"12:00 AM") 0,
Format(DateCollected, "mm/dd/yy hh:nn AM/PM"),
Format(DateCollected, "mm/dd/yy "))

Kevin C

"Ryan" <mi********@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
Hello,
I'm new to Access and DB's in general. I've taken over some light
duty support for a lab information system we use in house. Most of our
dates are reported as "10/31/2006 12:30:00 PM" (With seconds listed in
the report field).

However, nobody wants to see the seconds. So I tried to format it
=Format(DateCollected, "mm/dd/yy hh:nn AM/PM").

Works great, right? Well.. yeah for the most part. However if we
have something come in from a client and they list a date with no time,
then the report spits out "10/30/06 12:00 AM" since the date is empty,
the formatting assumes it's 0 Hour I guess.
So in short, the formatting works unless we have no time recorded for
the particular item we are testing.

Is there a way to get the format to ignore the hh:nn AM/PM section if
no time exists? Keep in mind these are when generating reports that go
back to the client... so they must be accurate.

Thank you, I hope I've made it clear what I'm looking for.

-Ryan

Oct 31 '06 #2
Kevin,
Yes I apologize, I meant time. There's always a date entered, but
sometimes not a time.

I'll give that a whack here.. I appreciate it.
Kc-Mass wrote:
Ryan
Try this. At one point you say the date is empty But I think you meant there
is no time, yes?

= IIF( Instr(Format(DateCollected, "mm/dd/yy hh:nn AM/PM"),"12:00 AM") 0,
Format(DateCollected, "mm/dd/yy hh:nn AM/PM"),
Format(DateCollected, "mm/dd/yy "))

Kevin C

"Ryan" <mi********@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
Hello,
I'm new to Access and DB's in general. I've taken over some light
duty support for a lab information system we use in house. Most of our
dates are reported as "10/31/2006 12:30:00 PM" (With seconds listed in
the report field).

However, nobody wants to see the seconds. So I tried to format it
=Format(DateCollected, "mm/dd/yy hh:nn AM/PM").

Works great, right? Well.. yeah for the most part. However if we
have something come in from a client and they list a date with no time,
then the report spits out "10/30/06 12:00 AM" since the date is empty,
the formatting assumes it's 0 Hour I guess.
So in short, the formatting works unless we have no time recorded for
the particular item we are testing.

Is there a way to get the format to ignore the hh:nn AM/PM section if
no time exists? Keep in mind these are when generating reports that go
back to the client... so they must be accurate.

Thank you, I hope I've made it clear what I'm looking for.

-Ryan
Oct 31 '06 #3
Kevin,

Ok it worked. Not at first, I had to adjust it to this:

=IIf(InStr(Format([DateCollected],"mm/dd/yy hh:nn AM/PM"),"12:00
AM")>0,Format([DateCollected],"mm/dd/yy"),Format([DateCollected],"mm/dd/yy
hh:nn AM/PM"))

So I just reversed the second and third Format statements....

Thanks!
Ryan wrote:
Kevin,
Yes I apologize, I meant time. There's always a date entered, but
sometimes not a time.

I'll give that a whack here.. I appreciate it.
Kc-Mass wrote:
Ryan
Try this. At one point you say the date is empty But I think you meant there
is no time, yes?

= IIF( Instr(Format(DateCollected, "mm/dd/yy hh:nn AM/PM"),"12:00 AM") 0,
Format(DateCollected, "mm/dd/yy hh:nn AM/PM"),
Format(DateCollected, "mm/dd/yy "))

Kevin C

"Ryan" <mi********@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
Hello,
I'm new to Access and DB's in general. I've taken over some light
duty support for a lab information system we use in house. Most of our
dates are reported as "10/31/2006 12:30:00 PM" (With seconds listed in
the report field).
>
However, nobody wants to see the seconds. So I tried to format it
=Format(DateCollected, "mm/dd/yy hh:nn AM/PM").
>
Works great, right? Well.. yeah for the most part. However if we
have something come in from a client and they list a date with no time,
then the report spits out "10/30/06 12:00 AM" since the date is empty,
the formatting assumes it's 0 Hour I guess.
>
>
So in short, the formatting works unless we have no time recorded for
the particular item we are testing.
>
Is there a way to get the format to ignore the hh:nn AM/PM section if
no time exists? Keep in mind these are when generating reports that go
back to the client... so they must be accurate.
>
Thank you, I hope I've made it clear what I'm looking for.
>
-Ryan
>
Oct 31 '06 #4
I wish I could go back and edit posts..

It seems to work on some of my "DateRecieved" Controlsource fields and
not on others... they all pull from the same table, but sometimes I get
stuff like #error rather than a date...
Ryan wrote:
Kevin,

Ok it worked. Not at first, I had to adjust it to this:

=IIf(InStr(Format([DateCollected],"mm/dd/yy hh:nn AM/PM"),"12:00
AM")>0,Format([DateCollected],"mm/dd/yy"),Format([DateCollected],"mm/dd/yy
hh:nn AM/PM"))

So I just reversed the second and third Format statements....

Thanks!
Ryan wrote:
Kevin,
Yes I apologize, I meant time. There's always a date entered, but
sometimes not a time.

I'll give that a whack here.. I appreciate it.
Kc-Mass wrote:
Ryan
Try this. At one point you say the date is empty But I think you meant there
is no time, yes?
>
= IIF( Instr(Format(DateCollected, "mm/dd/yy hh:nn AM/PM"),"12:00 AM") 0,
Format(DateCollected, "mm/dd/yy hh:nn AM/PM"),
Format(DateCollected, "mm/dd/yy "))
>
Kevin C
>
>
>
"Ryan" <mi********@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
Hello,
I'm new to Access and DB's in general. I've taken over some light
duty support for a lab information system we use in house. Most of our
dates are reported as "10/31/2006 12:30:00 PM" (With seconds listed in
the report field).

However, nobody wants to see the seconds. So I tried to format it
=Format(DateCollected, "mm/dd/yy hh:nn AM/PM").

Works great, right? Well.. yeah for the most part. However if we
have something come in from a client and they list a date with no time,
then the report spits out "10/30/06 12:00 AM" since the date is empty,
the formatting assumes it's 0 Hour I guess.


So in short, the formatting works unless we have no time recorded for
the particular item we are testing.

Is there a way to get the format to ignore the hh:nn AM/PM section if
no time exists? Keep in mind these are when generating reports that go
back to the client... so they must be accurate.

Thank you, I hope I've made it clear what I'm looking for.

-Ryan
Oct 31 '06 #5
I would guess those records have a null value - no date, no time

"Ryan" <mi********@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
>I wish I could go back and edit posts..

It seems to work on some of my "DateRecieved" Controlsource fields and
not on others... they all pull from the same table, but sometimes I get
stuff like #error rather than a date...
Ryan wrote:
>Kevin,

Ok it worked. Not at first, I had to adjust it to this:

=IIf(InStr(Format([DateCollected],"mm/dd/yy hh:nn AM/PM"),"12:00
AM")>0,Format([DateCollected],"mm/dd/yy"),Format([DateCollected],"mm/dd/yy
hh:nn AM/PM"))

So I just reversed the second and third Format statements....

Thanks!
Ryan wrote:
Kevin,
Yes I apologize, I meant time. There's always a date entered, but
sometimes not a time.

I'll give that a whack here.. I appreciate it.
Kc-Mass wrote:
Ryan
Try this. At one point you say the date is empty But I think you
meant there
is no time, yes?

= IIF( Instr(Format(DateCollected, "mm/dd/yy hh:nn AM/PM"),"12:00
AM") 0,
Format(DateCollected, "mm/dd/yy hh:nn AM/PM"),
Format(DateCollected, "mm/dd/yy "))

Kevin C

"Ryan" <mi********@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
Hello,
I'm new to Access and DB's in general. I've taken over some
light
duty support for a lab information system we use in house. Most of
our
dates are reported as "10/31/2006 12:30:00 PM" (With seconds listed
in
the report field).

However, nobody wants to see the seconds. So I tried to format it
=Format(DateCollected, "mm/dd/yy hh:nn AM/PM").

Works great, right? Well.. yeah for the most part. However if
we
have something come in from a client and they list a date with no
time,
then the report spits out "10/30/06 12:00 AM" since the date is
empty,
the formatting assumes it's 0 Hour I guess.
So in short, the formatting works unless we have no time recorded
for
the particular item we are testing.

Is there a way to get the format to ignore the hh:nn AM/PM section
if
no time exists? Keep in mind these are when generating reports
that go
back to the client... so they must be accurate.

Thank you, I hope I've made it clear what I'm looking for.

-Ryan

Nov 1 '06 #6
Ryan wrote:
Hello,
I'm new to Access and DB's in general. I've taken over some light
duty support for a lab information system we use in house. Most of our
dates are reported as "10/31/2006 12:30:00 PM" (With seconds listed in
the report field).

However, nobody wants to see the seconds.
Being a compulsive coder I would

1. create a function in the report's module as:

Private Function MySpecialDateFormat(ByVal d As Date) As String
MySpecialDateFormat = Format(d, "mm\/dd\/yyyy")
If Hour(d) 0 Or Minute(d) 0 Then _
MySpecialDateFormat = MySpecialDateFormat & _
Format(d, "\ hh:nn AM/PM")
End Function

(those things that look like \/ are one of these \ and one of these /
with no space between)

' gives
11/01/2006 for VBA.Date()
11/01/2006 07:43 AM for VBA.Now()

2. Set the control source to:
=MySpecialDateFormat([DateFieldName])

3. Access has this neat little trick. When a wizard creates a report it
names the control with the same name as the field. Then if we decide to
modify control source (as above) to use a function that refers to the
field's value it gives an error because, so it is said, in examining
the form it finds the control's name before it finds the field's name
and so think it has a circular reference. (This is really UGLY! [the
naming of the control with the same name as the field] and something MS
should have fixed years and years ago.) But there is a simple solution.
Be sure the field and the control do not have the same name.

Of course, you could make the function Public although there's not too
much point to that if you put it in the Report Module. If you make it
Public and put it into a Standard module then other objects and
procedures could use it.

Nov 1 '06 #7
Kevin,
No they most certainly do have dates. We generate several reports upon
recieving items and then again a different set of reports to give to
the client that tell them what we found with the items in question..

The DateRecieved field is the same for item "X" all the way through
the reporting process...

Not sure why the formatting works one place and tosses an #ERROR in
another.

Kc-Mass wrote:
I would guess those records have a null value - no date, no time

"Ryan" <mi********@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
I wish I could go back and edit posts..

It seems to work on some of my "DateRecieved" Controlsource fields and
not on others... they all pull from the same table, but sometimes I get
stuff like #error rather than a date...
Ryan wrote:
Kevin,

Ok it worked. Not at first, I had to adjust it to this:

=IIf(InStr(Format([DateCollected],"mm/dd/yy hh:nn AM/PM"),"12:00
AM")>0,Format([DateCollected],"mm/dd/yy"),Format([DateCollected],"mm/dd/yy
hh:nn AM/PM"))

So I just reversed the second and third Format statements....

Thanks!
Ryan wrote:
Kevin,
Yes I apologize, I meant time. There's always a date entered, but
sometimes not a time.

I'll give that a whack here.. I appreciate it.
Kc-Mass wrote:
Ryan
Try this. At one point you say the date is empty But I think you
meant there
is no time, yes?
>
= IIF( Instr(Format(DateCollected, "mm/dd/yy hh:nn AM/PM"),"12:00
AM") 0,
Format(DateCollected, "mm/dd/yy hh:nn AM/PM"),
Format(DateCollected, "mm/dd/yy "))
>
Kevin C
>
>
>
"Ryan" <mi********@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
Hello,
I'm new to Access and DB's in general. I've taken over some
light
duty support for a lab information system we use in house. Most of
our
dates are reported as "10/31/2006 12:30:00 PM" (With seconds listed
in
the report field).

However, nobody wants to see the seconds. So I tried to format it
=Format(DateCollected, "mm/dd/yy hh:nn AM/PM").

Works great, right? Well.. yeah for the most part. However if
we
have something come in from a client and they list a date with no
time,
then the report spits out "10/30/06 12:00 AM" since the date is
empty,
the formatting assumes it's 0 Hour I guess.


So in short, the formatting works unless we have no time recorded
for
the particular item we are testing.

Is there a way to get the format to ignore the hh:nn AM/PM section
if
no time exists? Keep in mind these are when generating reports
that go
back to the client... so they must be accurate.

Thank you, I hope I've made it clear what I'm looking for.

-Ryan
Nov 1 '06 #8
This point hit the nail on the head on my #ERROR rows. I just changed
the name field while leaving the control source the same....

I made the function public in a module called "DateFormat" since we
have several reports so making it a private function in each of them
didn't seem the best way to go about it. This just seemed more
'global', maybe I misunderstood what you meant about putting it in the
report module, though.

Thanks for the assitance.

3. Access has this neat little trick. When a wizard creates a report it
names the control with the same name as the field. Then if we decide to
modify control source (as above) to use a function that refers to the
field's value it gives an error because, so it is said, in examining
the form it finds the control's name before it finds the field's name
and so think it has a circular reference. (This is really UGLY! [the
naming of the control with the same name as the field] and something MS
should have fixed years and years ago.) But there is a simple solution.
Be sure the field and the control do not have the same name.

Of course, you could make the function Public although there's not too
much point to that if you put it in the Report Module. If you make it
Public and put it into a Standard module then other objects and
procedures could use it.
Nov 1 '06 #9

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

Similar topics

2
by: bissatch | last post by:
Hi, I am trying to use the following function: echo date("M", $i) to echo the date that the value of a variable, $i, represents (eg. 1 = Jan, 5 = May, 11 = Nov). Unfortunetely, it...
1
by: Simon Bailey | last post by:
I currently have a query calculating the gap in days between two dates. The fields being "DateLookedAt" and "DateResolved" plus the calculated field "TimeTaken". I am looking to add another...
59
by: Jeff Bowden | last post by:
For ease of configuration and other reasons, I would like for my single-user GUI app to be able to use postgresql in-process as a library accessing a database created in the users home directory. ...
5
by: Kiki | last post by:
Hello all. Probably I should be sending this to a different group so apologies if this seem out of place. We have an Access db in which people change data - as they do. When they do that, our SQL...
4
by: jonceramic | last post by:
Hi guys, I have a user who wants to have a report that shows only the 10th value recorded by his equipment. (i.e. His equipment records temperature every 30 seconds, but he only wants to view...
2
brettl
by: brettl | last post by:
Hey all. I'm not sure if this question should be posted here or in the XML forums. Please forgive me if its in the wrong place or feel free to move it. Any who, I'm using a SOAP service to...
3
by: kjworm | last post by:
Greetings, I have a report displayed on a screen that anyone in the office can look at. The data on this report will change from time to time. This report has different colors displayed...
71
by: Jack | last post by:
I understand that the standard Python distribution is considered the C-Python. Howerver, the current C-Python is really a combination of C and Python implementation. There are about 2000 Python...
18
by: 200dogz | last post by:
Hi, I have a aspx page that generates reports with the data it gets from databases. It used to work quick and fine until recently when a file is generated it gets killed a few seconds after...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.