Re: experience withh date searching
Re: experience withh date searching
- Subject: Re: experience withh date searching
- From: Robert Walker <email@hidden>
- Date: Fri, 1 Jul 2005 16:48:06 -0400
SELECT table.name where table.date >= NSTimestamp
I don't believe this is legal syntax in MySQL
Try something like this instead:
String sql = "SELECT * FROM some_table WHERE some_date >= " +
myTimestamp();
It's best to list all the fields you want to include in the SELECT
(instead of *) and provide proper Java keys for your dictionary in
the rawRowsForSQL(). But that's up to you.
Also note that it can be dangerous to use TIMESTAMP data type when
using MySQL. This field auto-updates when an UPDATE statement
doesn't provide a value. This can really confuse EOF, since the
value changes at the database level, and is not reflected in your
EOs. Consider using DATETIME instead, and update the value using EOF
as desired.
On Jul 1, 2005, at 5:49 AM, Gino Pacitti wrote:
Hi All
Im storing a TIMESTAMP with a record and using
EOUtilities.rawRowsForSQL to retrieve NSDictionaries
In the database the column TIMESTAMP is stored as 2005-06-30
00:59:59 +100 and I am constructing a select statement like this:
SELECT table.name where table.date >= NSTimestamp
This is the code for the creation of NSTimestamp:
NSTimeZone timeZoneNS = NSTimeZone.timeZoneWithName("England/
London", true);
NSTimestamp myNSTimestamp = new NSTimestamp();
GregorianCalendar myCalendar = new GregorianCalendar();
myCalendar.setTime(myNSTimestamp);
int year = myCalendar.get(GregorianCalendar.YEAR);
int dayOfMonth = myCalendar.get(GregorianCalendar.DAY_OF_MONTH);
int monthOfYear = myCalendar.get(GregorianCalendar.MONTH);
timestamp = new NSTimestamp(year, monthOfYear+1, dayOfMonth, 23,
59, 59, timeZoneNS);
yet I get this syntax error - Syntax error or access violation,
message from server: "You have an error in your SQL syntax near
'23:59:59 Etc/GMT' at line 1"
It seems that the timestamp created is wit Etc/GMT additional to
requirement but if I use null for timezone I still get the same.
How do I search for a TIMESTAMP in a sql query?
This is MySQL 3.23.52 on 10.4.1 with WO 5.2.3
I know the rawRowsFor SQL is deprecated but I still have a server
running 5.2.1
Best
Gino
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden