Page 1 of 1

OConv issue

Posted: Tue Nov 30, 2010 8:04 am
by dr.murthy
Hi

am going to convert the data from D/MDY(Time stamp) format to D-YMD date format using below syntax
OConv(IConv(Arg1[1,10],"D/MDY[2,2,4"),"D-YMD[4,2,2]")
But its failed for below dates.
06/1/2010 0:00:00 because its having data part as 8 characters.

any suggestions???

Posted: Tue Nov 30, 2010 8:07 am
by chulett
Use Field() rather than substring to get the date portion. You could also try using just "D" in the IConv call rather than your specific mask with those sizes, it is pretty darn smart about figuring dates out in its own.

Posted: Tue Nov 30, 2010 8:48 am
by dr.murthy
Thanks for respond, am not supposed to use field function for this scenario because
Source
6/1/2010 0:00:00 am getting o/p 2010-6-1 but i need 2010-06-01, so i used Conversion function to handle this .
its failed for this format (6/1/2010 0:00:00) dates, when i fetch first ten characters its getting 6/1/2010 0

Posted: Tue Nov 30, 2010 8:54 am
by chulett
:?

Use Field() to fetch the first field from a 'space' delimited string, then it won't matter how big it is... or isn't. You cannot simply fetch 10 characters when your date size is not fixed.

Posted: Tue Nov 30, 2010 12:48 pm
by vinnz
As craig suggested, use something like the below assuming your data is the first field in the space delimited string and there are no leading spaces

Code: Select all

Oconv(Iconv(Field(myDate,' ',1), "D/MDY"), "D-YMD[4,2,2]")