strip year out of TdateValue

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
HengeDK
Posts: 14
Joined: Wed Aug 29, 2012 9:09 pm

strip year out of TdateValue

Post by HengeDK »

Hi

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

how can I strip out the year

so I get "10/9"

Thanks
Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: strip year out of TdateValue

Post by Mark »

Hi too,

Code: Select all

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

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
HengeDK
Posts: 14
Joined: Wed Aug 29, 2012 9:09 pm

Re: strip year out of TdateValue

Post by HengeDK »

thanks a lot !
gpb01
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Sat Jun 04, 2011 5:41 pm

Re: strip year out of TdateValue

Post by gpb01 »

Or also ...

Code: Select all

put char 1 to 4 of tdateValue into tdateValue
:)

Guglielmo
Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: strip year out of TdateValue

Post by Mark »

Hi Guglielmo,

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

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
gpb01
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Sat Jun 04, 2011 5:41 pm

Re: strip year out of TdateValue

Post 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
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: strip year out of TdateValue

Post 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
gpb01
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Sat Jun 04, 2011 5:41 pm

Re: strip year out of TdateValue

Post 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
Post Reply