Topic: add N years to a date field
Hi,
How can I add 65 years to a date field in a SQLExecute ?? I've tried adddate but retuns "No such function". Any idea please?
Thanks in advance!
Javi
My Visual Database → SQL queries → add N years to a date field
Hi,
How can I add 65 years to a date field in a SQLExecute ?? I've tried adddate but retuns "No such function". Any idea please?
Thanks in advance!
Javi
Hello meideprac-x,
There is no adddate function in Sqlite, this is SQL or Mysql.
What you should do is :
date(date to modify,modifier)
OR
datetime(date to modify,modifier)
In one of my database this looks like this :
SELECT
datetime(asset.date_added) AS 'Original Date',
datetime(asset.date_added,'+65 year') AS 'Modified Date'
FROM
asset
WHERE
asset.id = 13
And the result is :
2016-06-25 11:10:45
2081-06-25 11:10:45
Cheers
Mathias
PS : the datetime function also gets ride of the trailing three 0 after hour/minutes/second and is good to use for formatting dates, that's why I added it to the first unmodified element of the query
SELECT datetime(asset.date_added) AS 'Original Date', datetime(asset.date_added,'+65 year') AS 'Modified Date' FROM asset WHERE asset.id = 13
Thanks Mathias, that works fine!!
Hello,
i am Beginner, and dont have a long experience with databases :§
i have a small Problem .
im My CALO Table there are 4 Fields for *Description, Period, Caldate, Duedate) and the Duedate should be= Caldate +Period , and the database has to do that automatically , i made a Button with SQL query to do that and it works good but when i search for my calculated Duedate i cant find it .
this is the SQL query
UPDATE CALO
SET Duedate = DATE(Caldate,'+365 Day')
where Period =365;
Thanks in advance for the help
sahems.y.3
Hello,
Please attach your project (zip file without exe and dll) and describe, what exactly you want to do in your project.
My Visual Database → SQL queries → add N years to a date field
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi