473,795 Members | 3,481 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 #1
11 7070
robtyketto
108 New Member
It appears ok with UK dates it doesnt like the time format for some reason.

Expand|Select|Wrap|Line Numbers
  1. mdm.Database.MSAccess.runQuery("UPDATE UserOverallResults SET Results = 10 WHERE UserName = 'Rob' AND quizDate = #19/02/2008# "); 
That code above runs without errors, when introducing time hh:mm: or hh:mm:ss it all goes wrong :-(
Mar 20 '08 #2
FishVal
2,653 Recognized Expert Specialist
It appears ok with UK dates it doesnt like the time format for some reason.

Expand|Select|Wrap|Line Numbers
  1. mdm.Database.MSAccess.runQuery("UPDATE UserOverallResults SET Results = 10 WHERE UserName = 'Rob' AND quizDate = #19/02/2008# "); 
That code above runs without errors, when introducing time hh:mm: or hh:mm:ss it all goes wrong :-(
Hi, Rob.

First of all you should never use date format other than US in SQL. The example you've provided works with UK format only because Access could not interpret it as valid US format date and makes necessary corrections.

The second thing - could you kindly explain what you mean by " ... it complains ..." in post #1.

The third - try to use single quote delimiters around date constants instead of #.

Regards,
Fish
Mar 20 '08 #3
robtyketto
108 New Member
Thanks for the reply.

I amended my actionscript code and now the date is stored as "mm/dd/yyyy hh:mm:ss" which populates the DATE/TIME field (QuizDate) in the access database.

TextDate is a string in actionscript which is used to successfully insert the QuizDate into the table as "mm/dd/yyyy hh:mm:ss"

When I want to update the table based on field Username and Date it goes horribly wrong:-

The code below:-
Expand|Select|Wrap|Line Numbers
  1. mdm.Database.MSAccess.runQuery("UPDATE UserOverallResults SET Results = " + UserScore + " WHERE UserName = '"+ UserName +"' AND QuizDate =  '"+textDate+"' "); 
Which puts SINGLE QUOTES around the Username and TextDate errors with message
Expand|Select|Wrap|Line Numbers
  1. Data type mismatch in criteria expression SQL statement
This code:-
Expand|Select|Wrap|Line Numbers
  1. mdm.Database.MSAccess.runQuery("UPDATE UserOverallResults SET Results = " + UserScore + " WHERE UserName = '"+ UserName +"' AND QuizDate =  #"+textDate+"# "); 
Which puts the user name in SINGLE QUOTES and the Date as #mm/dd/yyyy hh:mm:ss#

Which errors with :-
Expand|Select|Wrap|Line Numbers
  1. Parameter object is improperly defined. Inconsitent or incomplete information was provided SQL statement.
Mar 20 '08 #4
FishVal
2,653 Recognized Expert Specialist
Have you tried to run the same in Access query editor?
Mar 20 '08 #5
robtyketto
108 New Member
Thanks for the speedy reply.

When I was storing the dates in UK format in the database I could run the update query in Access with UserName and Date parameters without ANY problems with SINGLE QUOTES or #.

Since I changed the textDate within Actionscript and printed it out to american format "mm/dd/yyyy hh:mm:ss" I assumed it would be stored in the database in this way as I simply insert this String as is to a DATE/TIME field.

I've just checked teh database and its storing it in UK format ???
Suprised me, so the SQL qill be attempting to compare the UK format (stored in database) against textDate field (USA format).

Im looking now at why access would store it in UK format?
Mar 20 '08 #6
FishVal
2,653 Recognized Expert Specialist
To the best of my knowledge date format is only the way to represent date in Access table/query view unless the table field is of Text type. On the other hand SQL ANSI standard determines date constants to be used in US format.
These are separate things, they are not supposed to interfere.
Mar 20 '08 #7
robtyketto
108 New Member
Heres where I am right now with the problem and hopefully a clearer explanation of the current problem:-

I've written an application which stores the users name and current date.

In flash I've formatted a STRING with the date format of "mm/dd/yyyy hh:mm:ss" i.e. American Format

This STRING is then stored into the database without problems in a DATE/TIME field as "dd/mm/yyyy hh:mm:ss' as I am a UK user.

When I wish to update the table based on the value of User name and date the problems occur.

Expand|Select|Wrap|Line Numbers
  1. mdm.Database.MSAccess.runQuery("UPDATE UserOverallResults SET Results = " + UserScore + " WHERE UserName = '"+ UserName +"' AND format(QuizDate,(\"mm/dd/yyyy hh:nn:ss\")) =  #"+textDate+"# ");
Errors with

SQL query has failed for the following reason: Parameter object is improperly defined. Inconsistent or incomplete information was provided SQL statement: UPDATE OverallResults SET Results = 30 WHERE
UserName = 'sf' AND format(QuizDate ,(#mm/dd/yyy hh:nn:ss#) = #02/20/2008 15:45:38#

Testing shows if I remove the TIME part hh:mm:ss it runs without errors.

When testing SQL within Access its self all is ok no problems and happy if i use SINGLE QUOTES or HASH for date value, Ive been struggling with this for days.

Any help would greatly be appreciated.

Thanks
Rob W
Mar 20 '08 #8
FishVal
2,653 Recognized Expert Specialist
Ok, Rob.

I'm somewhat frustrated with it.
Your first syntax was just fine as for Jet SQL.
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# "); 
I will ask our community to pay attention to your question.

Regards,
Fish.
Mar 20 '08 #9
MMcCarthy
14,534 Recognized Expert Moderator MVP
Rob

One quick question. When storing the date in the database what is the data type of the field and assuming it's date/time what date format is defined?
Mar 20 '08 #10

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
35675
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
3332
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
2566
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
3844
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
3317
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
2580
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
3630
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
1940
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
10214
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10164
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
9042
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
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
6780
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
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3723
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
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.