You mean here: https://grasswiki.osgeo.org/wiki/SQL ?

-----Original Message-----
From: grass-user [mailto:grass-user-boun...@lists.osgeo.org] On Behalf Of 
Helmut Kudrnovsky
Sent: fredag 13. januar 2017 09.43
To: grass-user@lists.osgeo.org
Subject: Re: [GRASS-user] update column w/ output from bash function

Ken Mankoff wrote
> Hi Stefan,
> 
> Your code didn't seem to work for me, but allowed me to figure out how 
> to make it work. This does:
> 
> db.execute sql="UPDATE CTD_2015 SET YMD=date('2015-01-01', +CAST(DOY 
> AS
> text) || ' days');"
> 
> 
> I'm not sure why I can't simplify this to:
> 
> db.execute sql="UPDATE CTD_2015 SET YMD=date('2015-01-01', '+DOY days');"
> 
> But it is OK.
> 
> Thank you for the hint,
> 
>   -k.
> 
> On 2017-01-12 at 21:17, Blumentrath, Stefan <

> Stefan.Blumentrath@

> > wrote:
>> Hi Ken,
>>
>> In SQLite it would look like this:
> 
>> SELECT substr(CAST(date('2015-01-01', +CAST(DOY -1 AS text) || '
>> days') AS text), 6, 2);
>>
>> Or
>>
>> SELECT CAST(ltrim(substr(CAST(date(CAST(2015 AS text) || '-01-01',
>> +CAST(2-1 AS text) || ' days') AS text), 6, 2), '0')as smallint)
>>
>> If you want numeric return.
>>
>> Thus, try:
>>
>> db.select sql="SELECT substr(CAST(date('2015-01-01', +CAST(134 -1 AS
>> text) || ' days') AS text), 6, 2);"
>>
>> To see how it works...
>>
>> Then try something like:
>>
>> v.db.update map=CTD_2015 column=YMD value= 
>> substr(CAST(date('2015-01-01', +CAST(DOY -1 AS text) || ' days') AS 
>> text), 6, 2)
>>
>> or
>>
>> db.select sql="UPDATE CTD_2015 SET YMD = 
>> substr(CAST(date('2015-01-01', +CAST(134 -1 AS text) || ' days') AS 
>> text), 6, 2);"
>>
>> Cheers
>> Stefan
> _______________________________________________
> grass-user mailing list

> grass-user@.osgeo

> http://lists.osgeo.org/mailman/listinfo/grass-user

Would you mind to add some notes regarding date conversion to the wiki?

https://grasswiki.osgeo.org/wiki/GRASS-Wiki



-----
best regards
Helmut
--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/update-column-w-output-from-bash-function-tp5303075p5303302.html
Sent from the Grass - Users mailing list archive at Nabble.com.
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to