February 20, 2009
Date and Time to Number Conversions
Code developed and kindly donated by Murthy Suresh.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | function Date_To_Num( aaaammdd ) { dd_ = StrToNum( StrRight( aaaammdd, 2 ) ); //printf(WriteVal(dd_) + " " ); mm_ = StrToNum( StrMid( aaaammdd, 4, 2 ) ); //printf(WriteVal(mm_) + " " ); aa_ = StrToNum( StrLeft( aaaammdd, 4 ) ); //printf(WriteVal(aa_) + " " + "\n" ); Date_Num = ( 10000 * ( aa_ - 1900 ) ) + ( 100 * mm_ ) + dd_; RESULT = Date_Num; return RESULT; } function Time_To_Num( strTime ) // format for time is hh:mm:ss { /* //do something to raise alert if length does not match ????PopupWindow("Current time is: " + Now(),"Alert", 2, 640*mtRandom(), 480*mtRandom()); */ hh_t = StrToNum( StrLeft( strTime, 2 ) ); //printf(WriteVal( hh_t ) + " " ); mm_t = StrToNum( StrMid( strTime, 3, 2 ) ); //printf(WriteVal( mm_t ) + " " ); ss_t = StrToNum( StrRight( strTime, 2 ) ); //printf(WriteVal( ss_t ) + " " + "\n" ); Time_Num = 10000 * hh_t + 100 * mm_t + ss_t; RESULT = Time_Num; return RESULT; } |
Filed by Herman at 11:13 pm under AFL - Utilities and Functions, Uncategorized

