Page 1 of 1

strip year out of TdateValue

Posted: Tue Oct 09, 2012 7:55 pm
by HengeDK
Hi

I have a tdateValue like "10/9/12"

how can I strip out the year

so I get "10/9"

Thanks

Re: strip year out of TdateValue

Posted: Tue Oct 09, 2012 7:58 pm
by Mark
Hi too,

Code: Select all

set the itemDel to slash
delete item 3 of tdateValue
Kind regards,

Mark

Re: strip year out of TdateValue

Posted: Tue Oct 09, 2012 8:03 pm
by HengeDK
thanks a lot !

Re: strip year out of TdateValue

Posted: Tue Oct 09, 2012 9:25 pm
by gpb01
Or also ...

Code: Select all

put char 1 to 4 of tdateValue into tdateValue
:)

Guglielmo

Re: strip year out of TdateValue

Posted: Tue Oct 09, 2012 9:43 pm
by Mark
Hi Guglielmo,

That may not work. What if the month >= 10 o the day < 10?

Mark

Re: strip year out of TdateValue

Posted: Wed Oct 10, 2012 10:03 am
by gpb01
Mark wrote:Hi Guglielmo,

That may not work. What if the month >= 10 o the day < 10?

Mark
Correct ...
... this is why I still format all the date field to MM/DD/YYYY with a fixed number of chars (... using the leading zeros)

Guglielmo

Re: strip year out of TdateValue

Posted: Wed Oct 10, 2012 2:52 pm
by dunbarx
Correct ...
... this is why I still format all the date field to MM/DD/YYYY with a fixed number of chars (... using the leading zeros)
Fair enough, but then you would need to always get char 1 to 5 (not 1 to 4).

See what I mean? It is just a little dicey to write code that depends on an arbitrary format. But as long as you appreciate that setting the itemDel to "/" is more robust, in that it need not examine the length of the date string, go ahead. I have done worse.

Craig Newman

Re: strip year out of TdateValue

Posted: Wed Oct 10, 2012 3:46 pm
by gpb01
dunbarx wrote:
Correct ...
... this is why I still format all the date field to MM/DD/YYYY with a fixed number of chars (... using the leading zeros)
Fair enough, but then you would need to always get char 1 to 5 (not 1 to 4).

See what I mean? It is just a little dicey to write code that depends on an arbitrary format. But as long as you appreciate that setting the itemDel to "/" is more robust, in that it need not examine the length of the date string, go ahead. I have done worse.

Craig Newman
Hi Craig,
... the suggestion was only to show another possible LiveCode syntax to a new LiveCoder ;) (... I suppose ... we are in : "Getting Started with LiveCode - Complete Beginners" area).

Guglielmo