Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Date Time Format

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Date Time Format
Don 30.09.2006 23:33:01
I want to change the format of some code in a timer form that records the
date in a table to tell if the code was sucessfully run. What I would like to
do is change that code to include the time in the same field as the date if
possible as well. The following is the code that includes only the date:

strSQL = "UPDATE tblTimerDate SET LastTimerDate = " & _
' Format(Date, "\#mm/dd/yyyy\#")

On Error GoTo Err_Handler

If Time() > #5:10:00 AM# Then

If DLookup("LastTimerDate", "tblTimerDate") < Date Then

If DLookup("LastTimerDate", "tblTimerDate") < Date Then

Set dbs = CurrentDb
Set wrk = DAO.DBEngine.Workspaces(0)

' begin transaction
wrk.BeginTrans

****Several Code query instructions here then*****

' Update tblTimerDate table
strQuery = "embedded SQL to update tblTimerDate"
dbs.Execute strSQL, dbFailOnError

' no error so commit transaction This means that all of
' the queries above will be created. If the code stops,
' before commiting the transaction, the tables that are
' to be created will be created but only in the memory
' and if you keep running the code to debug the database
' you will get an error reporting that the tables exist
' even when you check the tables area in database window
' and you do not see them. The tables will be created once
' the commit transaction completes.

wrk.CommitTrans

The table that receives the date/time is formatted to General Date.

How can I add the time to this?

Thanks,

Dennis
Re: Date Time Format
"Rick Brandt" <rickbrandt2[ at ]hotmail.com> 30.09.2006 23:54:40
Don wrote:
[Quoted Text]
> I want to change the format of some code in a timer form that records
> the date in a table to tell if the code was sucessfully run. What I
> would like to do is change that code to include the time in the same
> field as the date if possible as well. The following is the code that
> includes only the date:
>
> strSQL = "UPDATE tblTimerDate SET LastTimerDate = " & _
> ' Format(Date, "\#mm/dd/yyyy\#")
>
> On Error GoTo Err_Handler
>
> If Time() > #5:10:00 AM# Then
>
> If DLookup("LastTimerDate", "tblTimerDate") < Date Then
>
> If DLookup("LastTimerDate", "tblTimerDate") < Date Then
>
> Set dbs = CurrentDb
> Set wrk = DAO.DBEngine.Workspaces(0)
>
> ' begin transaction
> wrk.BeginTrans
>
> ****Several Code query instructions here then*****
>
> ' Update tblTimerDate table
> strQuery = "embedded SQL to update tblTimerDate"
> dbs.Execute strSQL, dbFailOnError

Formatting means diddly squat. DateTimes are always STORED exactly the same.
If your "embedded SQL that you didn't share with us" includes a non-midnight
time component then it will be stored in the table along with the date.


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


Re: Date Time Format
John Vinson <jvinson[ at ]STOP_SPAM.WysardOfInfo.com> 01.10.2006 00:06:27
On Sat, 30 Sep 2006 16:33:01 -0700, Don
<Don[ at ]discussions.microsoft.com> wrote:

[Quoted Text]
>How can I add the time to this?

strSQL = "UPDATE tblTimerDate SET LastTimerDate = " & _
' Format(Now, "\#mm/dd/yyyy\ hh:nn:ss\#")

John W. Vinson[MVP]

Re: Date Time Format
Don 01.10.2006 00:26:01
Thank you John.
--
Thanks,

Dennis


"John Vinson" wrote:

[Quoted Text]
> On Sat, 30 Sep 2006 16:33:01 -0700, Don
> <Don[ at ]discussions.microsoft.com> wrote:
>
> >How can I add the time to this?
>
> strSQL = "UPDATE tblTimerDate SET LastTimerDate = " & _
> ' Format(Now, "\#mm/dd/yyyy\ hh:nn:ss\#")
>
> John W. Vinson[MVP]
>
>

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net