SQL problem with date variable

Discuss RoboTask here
Post Reply
breq
Posts: 13
Joined: Sun Feb 02, 2014 12:27 pm

SQL problem with date variable

Post 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?
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: SQL problem with date variable

Post 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}',...)
Oleg Yershov
breq
Posts: 13
Joined: Sun Feb 02, 2014 12:27 pm

Re: SQL problem with date variable

Post by breq »

that was it! thanks
Post Reply