View Full Version : CtoD
Chickenman
October 29th, 2009, 12:57 PM
This initially seemed straightforward, but I hope someone will break me through this mental block :confused:
I have three fields (columns) representing day, month, year - numeric converted to text and concatonated to give a date and then that field used in CtoD. But the result only yields values where the day and month are two digits.
Don't tell me I have to insert a '0' into the single character values! :eek:
CM
Data Kruncher
October 29th, 2009, 01:09 PM
Hi CM,
What's your formula?
Month, Day, and Year are all numeric fields in this test, and it works just fine for one and two digit days and/or months:
Ctod(str(Month)+str(Day)+str(Year),"m/d/y")
Chickenman
October 29th, 2009, 01:23 PM
Hi Sandy,
Yep, that works.
I made this more difficult than necessary by first changing the field type of the numeric to character then concatonating in a calculated field then using that field in a calculated CtoD. It got confused along the way I guess.
I appreciate the fast reply! :)
CM
Data Kruncher
October 29th, 2009, 01:34 PM
You're welcome!
To be honest, I didn't expect the above formula to work properly. Whenever I use Str() in combination with other functions, I tend to add an enclosing Trim(), and just to be safe I tend to add a couple of concatenating "/"s, like:
Ctod(trim(str(Month))+"/"+trim(str(Day))+"/"+trim(str(Year)),"m/d/y")
But it seems that Monarch is better able to handle values with CtoD than even I give it credit for, so given the test result above, I may well be overdoing things too. Better safe than sorry, though, right?
Chickenman
October 29th, 2009, 01:44 PM
Absolutely. The Trim might have avoided my issue in the first place but your approach is much cleaner.
CM
Powered by vBulletin™ Version 4.1.0 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.