Variable value vs Static inside the Sqlite datetime function.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Variable value vs Static inside the Sqlite datetime function.

Misfer Al-Shamrani
Hi everyone,

I’m looking for the proper presentation (syntax) that will use a dynamic value from the table instead of a fixed value as given in the common example below:

SELECT date('now','+1 month’);

= 2018-09-18

I want to replace the ( “+1” ….. months) with a dynamic value from my table field named “Months_Later” (integer datatype)  to give the date after the number of months in that field.

Thank you for your  assistance in this inquiry.

Misfer


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Variable value vs Static inside the Sqlite datetime function.

Richard Hipp-3
On 8/19/18, Misfer Al-Shamrani <[hidden email]> wrote:

> Hi everyone,
>
> I’m looking for the proper presentation (syntax) that will use a dynamic
> value from the table instead of a fixed value as given in the common example
> below:
>
> SELECT date('now','+1 month’);
>
> = 2018-09-18
>
> I want to replace the ( “+1” ….. months) with a dynamic value from my table
> field named “Months_Later” (integer datatype)  to give the date after the
> number of months in that field.


   SELECT date('now',printf('%+d months',tab.Months_Later)) FROM tab;

--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Fim
Reply | Threaded
Open this post in threaded view
|

Re: Variable value vs Static inside the Sqlite datetime function.

Fim
Will I works even If the date is 2018-12-18 ?
Fim Wästberg, Sweden

-----Ursprungligt meddelande-----
Från: sqlite-users <[hidden email]> För Richard Hipp
Skickat: den 21 augusti 2018 13:01
Till: SQLite mailing list <[hidden email]>
Ämne: Re: [sqlite] Variable value vs Static inside the Sqlite datetime function.

On 8/19/18, Misfer Al-Shamrani <[hidden email]> wrote:

> Hi everyone,
>
> I m looking for the proper presentation (syntax) that will use a
> dynamic value from the table instead of a fixed value as given in the
> common example
> below:
>
> SELECT date('now','+1 month );
>
> = 2018-09-18
>
> I want to replace the (  +1   .. months) with a dynamic value from my
> table field named  Months_Later  (integer datatype)  to give the date
> after the number of months in that field.


   SELECT date('now',printf('%+d months',tab.Months_Later)) FROM tab;

--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Variable value vs Static inside the Sqlite datetime function.

Richard Hipp-3
On 8/21/18, Fim Wästberg <[hidden email]> wrote:
> Will I works even If the date is 2018-12-18 ?

How hard is it to try and see for yourself?

--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users