Page 1 of 1

SQL problem with date variable

Posted: Sat Jan 10, 2015 1:02 am
by breq
So when i select max(date) from table and save it as variable MAX. Next alert it, messagebox will show me "2015-01-10" - actual date.
Next I'm trying to put that variable {MAX} to database and it inserts '2014' because 2015-1-10 = 2004...

How to avoid this problem?

Re: SQL problem with date variable

Posted: Sat Jan 10, 2015 9:51 am
by Oleg
I'd like to see you INSERT SQL expression.
It seems you use only {MAX} without single quotes like this:
insert into myTable (field1, ...) values ({max},...)

your expression will be transformed into expression:
insert into myTable (field1, ...) values (2015-1-10,...)
In this case SQL engine think that it is an arithmetical expression and calculates it

Try to use '{MAX}' (with quotes)
The SQL expression will be like this:
insert into myTable (field1, ...) values ('{max}',...)

Re: SQL problem with date variable

Posted: Sat Jan 10, 2015 2:33 pm
by breq
that was it! thanks