473,804 Members | 3,739 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access/Jet SQL: Date/time issues

108 New Member
Greetings,

I'm using Flash MX connecting to an MS Access database via JET.

I've stored dates using Flash/Jet into my database as 'dd/mm/yyyy hh:mm:ss' into a DATE/TIME field.

However I can't update because of the WHERE clause as I am not specifying the date correctly. I believe syntax wise I need to use # and specify it in american format mm/dd/yyyy hh:mm:ss.

I have the code below working :-
Expand|Select|Wrap|Line Numbers
  1. mdm.Database.MSAccess.runQuery("UPDATE UserOverallResults SET Results = 10 WHERE UserName = 'Rob' AND quizDate > #02/19/2008#"); 
When I add the time it complains and using the "=" clause it complains :-
Expand|Select|Wrap|Line Numbers
  1. mdm.Database.MSAccess.runQuery("UPDATE UserOverallResults SET Results = 10 WHERE UserName = 'Rob' AND quizDate = #02/19/2008 12:03:32# "); 
Can anyone please assist, ive spent hours messing around with date/time formats, very confused.

Thanks
Rob W
Mar 19 '08
11 7071
sierra7
446 Recognized Expert Contributor
Hi Rob

I sympathise because I'm a UK user too. Just a couple of things tho'; in the 'database' the date part is stored as an integer and the time part as decimal day, so the reason for putting a Format() around a date is to inform Access that the character string is to be interpreted as a UK date, so it is then converted to the right valued number for storage. When you view the Table you are seeing it in UK format because of your environment settings.

If you go into Table Design you can change the format to Long Date, Medium date etc. then open the table to see the changes. If you want to be perverse you could change the format to mmm-dd-yyyy then a date of 1st Jan in your table would appear as Jan-01-2008, even though you had entered it as 01-Jan-08.

Now to your problem; when you created the table did you specify General Date (ie with the Time part) ? If you did not I'm pretty sure that Access will not bother with the 'decimal day' and just store the date as an integer. This may be consistent with your findings that it works ok with just dates but 'hh:mm:ss' cause it to fail. So, when you open your table can you see hours-minutes-seconds?

When concatonating in Access(VBA) I always use the ampersand (&) not a plus (+) sign, even though the 'plus' may be acceptable it confuses the hell out of me.

Incidentally, when I want both date and time I (wastefully) create two fields one for date and the other for time. It saves time with the complications your faced with.

S7
Mar 20 '08 #11
NeoPa
32,579 Recognized Expert Moderator MVP
Rob,

There seems to be a lot of confusion surrounding this issue so firstly I would suggest reading Literal DateTimes and Their Delimiters (#).

Essentially, you need to understand the difference between what is inside the SQL string and is referring to a literal date (always use # to identify date/times btw) - and what is stored internally as a date.

When you display a date/time field value then it will use your local settings. That certainly does NOT mean it is stored in UK format or whatever else you have set. It is stored as a number (non-integral except for pure dates) and only displayed as a date.

This format is entirely irrelevant when using date literals in SQL. They are in US m/d/yy mode exclusively. Your example earlier worked as Access realised that the particular data you supplied could ONLY be interpreted as d/m/yy so automatically switched it for you. This would not happen for a date such as 2/5/2007 - hence the importance of getting it done the correct way.

@Sierra + =/= & where strings are concerned.
The difference (s1 & s2 == s1 + s2 == s1s2 but s1 & Null == s1 whereas s1 + Null == Null) can be very usefully used in VBA code to drop associated parts of a SQL clause when an item is Null.
Mar 21 '08 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1863
by: David | last post by:
We recently translated the backend db from Access(97) to SQL Server. We are still using Access frontends. I have an update query in the Access front end that uses a lookup table to populate fields. The common fields between the table and the lookup table are the primary key (LocID) and date & time fields. The query is: UPDATE tblPT_Offsets INNER JOIN tblPT ON tblPT_Offsets.LocID = tblPT.LocID SET tblPT.Offset_ft = ., tblPT.Salinity =...
7
35677
by: Bob | last post by:
Currently I am using this statement to translate 3 fields in my db thru Visual Basic. I import the data from one table to another then call the IFF statements and the NewDate to translate the fields. Can this be done in an Access db? I am trying to learn how to do these things in Access vs Visual Dim strIIF As String Dim sstrIIF As String Dim strNewDate As Date
13
3334
by: BigDaDDY | last post by:
Um yeah....In case you haven't figured it out, Microsoft sucks. I'm going to be kicked back in my chair eating popcorn and watching football 10 years from now, while all you clowns are scrambling to rewrite all your code because Microsoft upgraded all their crap and nothing you wrote 10 years earlier works. It doesn't take a rocket scientist to figure out that Microsoft is unreliable. Try opening an Excel 95 spreadsheet you wrote in...
5
2568
by: Henning M | last post by:
Hi all, I having some problems with Access and selecting records between dates.. When I try this in access, it works fine!! "Select * from Bilag Where Mdates Between #1/1/2006# And #31/1/2006#" But when I try it from my vb.net app, I get ALL the records in the tabel?? What goes wrong? I haven't been able to find any info on the net, besides others having
1
3846
by: ken | last post by:
Hi, Lets say we have a form that displays time card entries based on the calendar control date on the form. So the user clicks on a date and the form filters the table where the time card entries come from to get you proper data. In access I would just filter the query(rewrite its qrydef) and I'd get my answer. My question is, what is the proper way of doing this in ADP and SQL Server 2005. I could filter the data from the view on the...
3
3318
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when the field should only be showing one or the other (date or time). Even on the back end of the database where the column properties are, I have chosen the smallest date/time formats. When the aspx page runs, it shows the date and time (ie:in a...
11
2583
by: Chad | last post by:
Hi Is it possible to substitute an alternative data source (eg MySQL or SQL Server) into an existing MS-Access application?
2
3632
by: slb813 | last post by:
Hello all, I am new to php and I can't seem to get some code to insert information into a Access database. I am running Apache 2.2 server with php 5.1.2 and on a Windows XP SP2 platform. Here is the code I am attempting to get running, if someone is intrested in helping a new php person out. <?php $Fname = $_POST; $Fphone = $_POST; $Fproblem = $_POST; $Fdate = date("m/d/Y");
10
1943
by: Scott M. | last post by:
I've seen many posts and ready articles discussing how changing the membership & roles "provider" in VS .NET is easy, but have yet to see instructions on how to do it. If I already have SQL Server 2000 on a machine and didn't install SQL Server 2005 Express with my VS .NET installation, how do I set up my existing SQL 2000 server to be the membership & roles provider for ASP .NET?
6
6225
by: Mark | last post by:
Currently using MS Access 2000 and SQL Server Express. Using the current DAO OpenRecordset code listed below, however I keep getting the error message.... 3254: ODBC --Cannot lock all records The code below runs in a MS Access frontend while the table is linked using an ODBC connected to an SQL Server (backend). The table (located in SQL) only has one row and one column within it . I want to try and stop any other request (other...
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9582
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7621
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2993
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.