From: Sabosis on
Hello-

I have a form that is used to update records in an table. The table
has a field called "RecordUpdated" that gets a date from the form when
the form record is updated. I used the following code on the forms
BeforeUpdate event:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me!RecordUpdated = Now()
End Sub

The field in the table is getting updated as planned. The problem I am
having is that I have a form used to generate reports on how many
records were updated on a specific date, etc. The form is based on a
query and has parameter fields in it to select the dates you want to
report against. I choose single date, the report returns no info. If I
use a range of two dates, like start date and end date, but use the
same date in both fields, the report returns no info. The only way I
can get info to show up for say March 12, 2010 would be to put
3/12/2010 in the start date field and 3/13/2010 in the end date
field.

Does anyone know what is wrong with this? Is it something to do with
the format properties of the dates? Should I use =Date() instead of
=Now() in the main forms BeforeUpdate event? Please help if
possible....

Thanks

Scott
From: Sabosis on
On Mar 21, 9:12 am, Sabosis <scott.s...(a)henryschein.com> wrote:
> Hello-
>
> I have a form that is used to update records in an table. The table
> has a field called "RecordUpdated" that gets a date from the form when
> the form record is updated. I used the following code on the forms
> BeforeUpdate event:
>
> Private Sub Form_BeforeUpdate(Cancel As Integer)
> Me!RecordUpdated = Now()
> End Sub
>
> The field in the table is getting updated as planned. The problem I am
> having is that I have a form used to generate reports on how many
> records were updated on a specific date, etc. The form is based on a
> query and has parameter fields in it to select the dates you want to
> report against. I choose single date, the report returns no info. If I
> use a range of two dates, like start date and end date, but use the
> same date in both fields, the report returns no info. The only way I
> can get info to show up for say March 12, 2010 would be to put
> 3/12/2010 in the start date field and 3/13/2010 in the end date
> field.
>
> Does anyone know what is wrong with this? Is it something to do with
> the format properties of the dates? Should I use =Date() instead of
> =Now() in the main forms BeforeUpdate event? Please help if
> possible....
>
> Thanks
>
> Scott

Well, I guess I should try harder before seeking help. Changing from
=Now() to =Date() worked and I and getting records for single dates in
my reports now :-) . Thanks anyway for the help, i know someone would
have pointed me in the right direction!

Scott
From: John W. Vinson on
On Sun, 21 Mar 2010 09:17:52 -0700 (PDT), Sabosis <scott.sabo(a)henryschein.com>
wrote:

>Well, I guess I should try harder before seeking help. Changing from
>=Now() to =Date() worked and I and getting records for single dates in
>my reports now :-) . Thanks anyway for the help, i know someone would
>have pointed me in the right direction!

As you discovered, Now() does not store today's date: it stores the date and
time, accurate to the second (actually to a few microseconds but only
displayed to the second). This can be very useful if you want an accurate
timestamp of when a record was created.

You can use a criterion of

>= [Date parameter] AND < [Date parameter] + 1

to get all times within a date.
--

John W. Vinson [MVP]
From: Krzysztof Naworyta on
John W. Vinson wrote:


(...)
| actually to a few microseconds
| but only displayed to the second

???

Now() returns current time accurate to the ONE second:

Sub timeTest()
Dim i As Long
Dim t As Double, t0 As Double

For i = 1 To 10000000
t = CDbl(Now)
If t0 <> t Then
Debug.Print i, CDec(t - t0), CDate(t)
t0 = t
End If
Next
End Sub

'---results:-------------
1 40260,4585185185 2010-03-23 11:00:16
1041563 0,0000115740695036948 2010-03-23 11:00:17
2586114 0,0000115740767796524 2010-03-23 11:00:18
4137390 0,0000115740767796524 2010-03-23 11:00:19
5681941 0,0000115740695036948 2010-03-23 11:00:20
7237547 0,0000115740767796524 2010-03-23 11:00:21
8787166 0,0000115740695036948 2010-03-23 11:00:22



--
KN
From: John W. Vinson on
On Tue, 23 Mar 2010 11:04:19 +0100, "Krzysztof Naworyta"
<k.naworyta(a)datacomp.com.pl> wrote:

>John W. Vinson wrote:
>
>
>(...)
>| actually to a few microseconds
>| but only displayed to the second
>
>???
>
>Now() returns current time accurate to the ONE second:

I misspoke. I meant that the Date/Time datatype is capable of storing time
accurate to microseconds but is only usable to the second.
--

John W. Vinson [MVP]