PC Review


Reply
Thread Tools Rate Thread

Date & Time A97

 
 
Kahuna
Guest
Posts: n/a
 
      20th Feb 2007
Hi Folks

This seems like it should be simple - so perhaps I have my STOOPID head on
today or something!

I am writing a login app and I need to record the date AND time the user
logged in. Sounds simple enough:

tblLoggedIn![li_date_time] (General Date Format)

In the table view the record shows only the date - but no time?

My target is to use a form with something like the following:

...."Where DatePart("n",[li_date_time]) > DatePart("n",Now())-2"

Saying: where the last logged in time was longer than 2 mins ago!

Even just using DatePart("n",[li_date_time]) simply results in an ambiguous
number.

Have I got this completely wrong? How do I set the field to reference both
date and time together?

Help appreciated.

--
Kahuna
------------


 
Reply With Quote
 
 
 
 
Rick Brandt
Guest
Posts: n/a
 
      20th Feb 2007
Kahuna wrote:
> Hi Folks
>
> This seems like it should be simple - so perhaps I have my STOOPID
> head on today or something!
>
> I am writing a login app and I need to record the date AND time the
> user logged in. Sounds simple enough:
>
> tblLoggedIn![li_date_time] (General Date Format)
>
> In the table view the record shows only the date - but no time?
>
> My target is to use a form with something like the following:
>
> ..."Where DatePart("n",[li_date_time]) > DatePart("n",Now())-2"
>
> Saying: where the last logged in time was longer than 2 mins ago!
>
> Even just using DatePart("n",[li_date_time]) simply results in an
> ambiguous number.
>
> Have I got this completely wrong? How do I set the field to reference
> both date and time together?
>
> Help appreciated.


You don't say how you are populating the field. Are you setting it in code
using the Now() function? Is the user entering the value manually? If the
latter are they entering a time? Entering a date only will not default to the
current time. It will default to midnight which (by default) Access does not
display.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


 
Reply With Quote
 
John Spencer
Guest
Posts: n/a
 
      20th Feb 2007
Use the DateAdd function in your where clause

WHERE li_date_time > DateAdd("s",-120, Now())

Since we don't know how you are populating li_date_time , it is hard to
advise you why the time is not showing.
If you are using the Date() function that only gives the system date (time
as midnight). IF you use Now() that gives both date and time.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Rick Brandt" <(E-Mail Removed)> wrote in message
news:XSBCh.26008$(E-Mail Removed)...
> Kahuna wrote:
>> Hi Folks
>>
>> This seems like it should be simple - so perhaps I have my STOOPID
>> head on today or something!
>>
>> I am writing a login app and I need to record the date AND time the
>> user logged in. Sounds simple enough:
>>
>> tblLoggedIn![li_date_time] (General Date Format)
>>
>> In the table view the record shows only the date - but no time?
>>
>> My target is to use a form with something like the following:
>>
>> ..."Where DatePart("n",[li_date_time]) > DatePart("n",Now())-2"
>>
>> Saying: where the last logged in time was longer than 2 mins ago!
>>
>> Even just using DatePart("n",[li_date_time]) simply results in an
>> ambiguous number.
>>
>> Have I got this completely wrong? How do I set the field to reference
>> both date and time together?
>>
>> Help appreciated.

>
> You don't say how you are populating the field. Are you setting it in
> code using the Now() function? Is the user entering the value manually?
> If the latter are they entering a time? Entering a date only will not
> default to the current time. It will default to midnight which (by
> default) Access does not display.
>
> --
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt at Hunter dot com
>



 
Reply With Quote
 
Kahuna
Guest
Posts: n/a
 
      20th Feb 2007
"Rick Brandt" <(E-Mail Removed)> wrote in message
news:XSBCh.26008$(E-Mail Removed)...
> Kahuna wrote:
>> Hi Folks
>>
>> This seems like it should be simple - so perhaps I have my STOOPID
>> head on today or something!
>>
>> I am writing a login app and I need to record the date AND time the
>> user logged in. Sounds simple enough:
>>
>> tblLoggedIn![li_date_time] (General Date Format)
>>
>> In the table view the record shows only the date - but no time?
>>
>> My target is to use a form with something like the following:
>>
>> ..."Where DatePart("n",[li_date_time]) > DatePart("n",Now())-2"
>>
>> Saying: where the last logged in time was longer than 2 mins ago!
>>
>> Even just using DatePart("n",[li_date_time]) simply results in an
>> ambiguous number.
>>
>> Have I got this completely wrong? How do I set the field to reference
>> both date and time together?
>>
>> Help appreciated.

>
> You don't say how you are populating the field. Are you setting it in
> code using the Now() function? Is the user entering the value manually?
> If the latter are they entering a time? Entering a date only will not
> default to the current time. It will default to midnight which (by
> default) Access does not display.
>
> --
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt at Hunter dot com


Thanks Rick - that answers my question - I was having the field populated by
hand as a test - using the Now() function does populate it accurately.

AND

I found using the DateDiff() function instead of the DatePart() I was able
to determine the duration accurately too.

Brilliant Cheers Bud.

--
Kahuna
------------


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting text format of time/date into Excel time/date for subtr YY san. Microsoft Excel Worksheet Functions 5 25th Feb 2010 08:13 AM
Calculating days & time left from start date/time to end date/time =?Utf-8?B?bWFyaWU=?= Microsoft Excel Worksheet Functions 7 7th Dec 2005 03:36 PM
Date/Time datatype in Access 2003 affects date/time duplicate quer =?Utf-8?B?VGltIFQ=?= Microsoft Access Queries 4 27th Jun 2005 03:20 AM
Medium Time setting does not hide date from a date/time duplicateq =?Utf-8?B?VGltIFQ=?= Microsoft Access Getting Started 0 26th Jun 2005 09:49 PM
Calc. Length of time with time-in, time-out, date-in, date-out in diff. columns Niceven Microsoft Excel Misc 2 28th May 2004 05:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:54 PM.