Page 2 of 2
Re: SOLVED function to get MM-DD-YY
Posted: Fri Sep 06, 2013 12:44 am
by wee wullie
Hi everyone, i managed to solve my problem by dissecting the system date and re-arranging char by char and removing the first 2 digits of the year item, the code i used is thus:
Code: Select all
put text of fld "Date1" into tDate
put char 4 to 5 of tDate & "/" & char 1 to 2 of tDate & "/" & char 9 to 10 of tDate into fld "Date1"
and it works perfectly, no dateitems, no converting to other formats, just pop it into a var and re-arrange and job done, does seem a little
too simple though, but it does work.
Very big thanks to all,
kindest regards
wee
Re: function to get MM-DD-YY
Posted: Fri Sep 06, 2013 5:53 am
by dunbarx
Hi.
Nothing wrong with simple.
But your method relies on a consistent format in your starting date. If you are confident about that, there is no reason not to do it that way. But in general, where the several components of a date might have different numbers of chars, for example, your system would break.
But the exercise itself is just as important. Keep fooling around.
Craig
Re: function to get MM-DD-YY
Posted: Fri Sep 06, 2013 8:49 am
by bn
Hi wee,
sorry I did not read your format correctly.
try this
Code: Select all
on mouseUp
put text of fld "Date1" into tDate
set the itemdelimiter to "/" -- this lets you treat a slash as itemDelimiter
put item 2 of tDate into item 1 of tDestFormat -- items are automatically formed with the current itemDelimiter
put item 1 of tDate into item 2 of tDestFormat
put char -2 to - 1 of item 3 of tDate into item 3 of tDestFormat -- get only the last two digits
set the itemdelimiter to comma -- be nice and reset the itemDelimiter, would be reset at end of handler anyways though
answer tDestFormat
end mouseUp
Kind regards
Bernd
Re: function to get MM-DD-YY
Posted: Fri Sep 06, 2013 10:59 am
by wee wullie
Nice 1 Bernd, that works perfectly, and thanks to all, i have attached
the date picker i use, as i said in an earlier post this date picker was originally on revonline by Marty and was subsequently modified by BVG, i use it in lots of stacks and it works well.
king regards
wee