Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / December 2004

Tip: Looking for answers? Try searching our database.

Problem with time in access

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kenny M. - 25 Dec 2004 19:25 GMT
HI

In Access the date is like

21/12/2004 08:57:17 a.m.

I need to update the record only if it was not created more than five
minutes ago

cmd = "UPDATE Sales SET Status = 'A' WHERE Mid(SalesDate,13,20) > #" &
Mid(Microsoft.VisualBasic.DateAdd(DateInterval.Minute, -5,
DateTime.Parse(DateTime.Now.ToShortTimeString, myFormat)), 13, 20) & "#"

e.g

When the time is 2:07:00 p.m.

I can see the query goes to ADO like this

"UPDATE Sales SET Status = 'B' WHERE Mid(SalesDate,13,20) > #2:02:00 p.m.#"

but there is a syntax error, any idea

thks
Jim Hughes - 26 Dec 2004 04:18 GMT
Mid is using Access's VBA implementation and not Microsoft JET SQL, which
is what ADO and ADO.Net will use.

The equivalent string command for JET SQL would be SUBSTRING

See the Access Table of Contents and scroll down to Microsoft Jet SQL
Reference.

Here are the other String commands, listed under ODB Scalar Functions

     ASCII LENGTH RTRIM
     CHAR LOCATE SPACE
     CONCAT LTRIM SUBSTRING
     LCASE RIGHT  UCASE
     LEFT

> HI
>
[quoted text clipped - 21 lines]
>
> thks
Paul Clement - 27 Dec 2004 17:37 GMT
¤ HI
¤
¤ In Access the date is like
¤
¤ 21/12/2004 08:57:17 a.m.
¤
¤ I need to update the record only if it was not created more than five
¤ minutes ago
¤
¤
¤ cmd = "UPDATE Sales SET Status = 'A' WHERE Mid(SalesDate,13,20) > #" &
¤ Mid(Microsoft.VisualBasic.DateAdd(DateInterval.Minute, -5,
¤ DateTime.Parse(DateTime.Now.ToShortTimeString, myFormat)), 13, 20) & "#"
¤
¤ e.g
¤
¤ When the time is 2:07:00 p.m.
¤
¤ I can see the query goes to ADO like this
¤
¤ "UPDATE Sales SET Status = 'B' WHERE Mid(SalesDate,13,20) > #2:02:00 p.m.#"
¤
¤ but there is a syntax error, any idea

You don't want to use the MID function, although it would be available if sandbox mode for Jet is
enabled. Use the DateDiff function instead in order to determine whether the interval between dates
is greater than five minutes.

See the following in order to determine whether sandbox mode is properly enabled:

http://support.microsoft.com/default.aspx?scid=kb;en-us;294698

Paul ~~~ pclement@ameritech.net
Microsoft MVP (Visual Basic)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.