Author Topic: Date field output conversion this: YYYYMM not this: YYYY MM  (Read 119 times)

Chris Weitzel

  • Professional
  • ***
  • Posts: 29
Experts,
How would I convert a date field to get this YYYYMM format instead of YYYY MM?  Conversion DYM produces a space between the year and month.
Chris

precisonline

  • President
  • Administrator
  • Rock Star
  • *****
  • Posts: 1583
    • Precision Solutions
Re: Date field output conversion this: YYYYMM not this: YYYY MM
« Reply #1 on: May 12, 2017, 08:38:38 pm »
If you can double convert, apply a D4YM first, then an MCN to strip the space.  Here's a couple of ways to do it with the current date - you can test these with /EE:

(@DATE"D4YMD")"MCN"


...or...


OCONV(@DATE,'D4YM' : @VM : 'MCN')


« Last Edit: May 12, 2017, 08:49:48 pm by precisonline »
-Kevin
Accidents "happen"; success, however, is planned and executed.

Chris Weitzel

  • Professional
  • ***
  • Posts: 29
Re: Date field output conversion this: YYYYMM not this: YYYY MM
« Reply #2 on: May 15, 2017, 06:51:15 am »
Perfect!  Thanks.

Just curious.  Is there a way to do the same conversion in a dictionary on the "Conversion" line rather than creating a derived field?

The only reason I ask is that there seems to be better select/list performance using the real attribute compared to the derived field.  In my limited testing, using the Conversion field with "DYM" and entering a date range >= "2017 01" and <= "2017 04" produces faster results than the derived field with the conversion, using those same dates but without the space between year and month.

I may be imagining the performance difference, but it's not unreasonable to think that direct attribute conversion as part of a list statement would be at least modestly faster than using a derived field.  Could be wrong though.


precisonline

  • President
  • Administrator
  • Rock Star
  • *****
  • Posts: 1583
    • Precision Solutions
Re: Date field output conversion this: YYYYMM not this: YYYY MM
« Reply #3 on: May 17, 2017, 07:05:13 am »
You could always do something like this as the conversion:


((@VALUE"D4YMD")"MCN")


In a conversion, @VALUE is always the value to be converted.  And surrounding it with the (  ) lets you use any of the SB+ expression stuff to do the double conversion.
-Kevin
Accidents "happen"; success, however, is planned and executed.

Chris Weitzel

  • Professional
  • ***
  • Posts: 29
Re: Date field output conversion this: YYYYMM not this: YYYY MM
« Reply #4 on: May 18, 2017, 06:51:36 am »
Fantastic!

Thanks a ton.