Date Format Problem

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Tourless
Pro Scripter
Posts: 69
Joined: Wed Jun 14, 2017 1:53 am
Location: NY

Date Format Problem

Post by Tourless » Thu Jun 06, 2019 3:43 pm

Hi Folks,

I've searched around and read a fair deal of posts regarding date formats. I understand how they tie to the system settings but I'm not able to find a post that addresses my need to format a date with the month spelled out. I know in some of my excel code I can specify a date format as MMMM and it returns 'June'. Can I accomplish this in MS? Can someone help point me in the right direction?
TIA

Tourless
Pro Scripter
Posts: 69
Joined: Wed Jun 14, 2017 1:53 am
Location: NY

Re: Date Format Problem

Post by Tourless » Thu Jun 06, 2019 5:32 pm

Well I came up with something that I don't think is pretty but it works... I'd love to hear how others have solved this problem, I can't be the only one. :D

Code: Select all

Month>m
If>m=01
  mm=January
  ELSE
    IF>m=02
    Let>mm=February
    ELSE
      IF>m=03
      Let>mm=March
      ELSE
        IF>m=04
        Let>mm=April
        ELSE
          IF>m=05
          Let>mm=May
          ELSE
            IF>m=06
            Let>mm=June
            ELSE
              IF>m=07
              Let>mm=July
              ELSE
                IF>m=08
                Let>mm=August
                ELSE
                  IF>m=09
                  Let>mm=September
                  ELSE
                    IF>m=10
                    Let>mm=October
                    ELSE
                      IF>m=11
                      Let>mm=November
                      ELSE
                        IF>m=12
                        Let>mm=December
                        ENDIF
                      ENDIF
                    ENDIF
                   ENDIF
                ENDIF
              ENDIF
            ENDIF
          ENDIF
        ENDIF
      ENDIF
    ENDIF
  ENDIF
Day>d
Let>dd=d-1
Year>y
MessageModal>File name is %mm% %dd% %y%

User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Date Format Problem

Post by Grovkillen » Thu Jun 06, 2019 8:04 pm

Code: Select all

GoSub>MONTHS_FIX

Month>MONTH_NUMBER
MidStr>1,1,TEST
If>TEST=0
MidStr>2,1,MONTH_NUMBER
EndIf>
Let>VERBOSE_MONTH_NAME=MONTH_NAME_%MONTH_NUMBER%

SRT>MONTHS_FIX
Let>RAW_LIST=January|February|March|April|May|June|July|August|September|October|November|December
Separate>RAW_LIST,|,MONTH_NAME
END>MONTHS_FIX 
Let>ME=%Script%

Running: 15.0.24
version history

Tourless
Pro Scripter
Posts: 69
Joined: Wed Jun 14, 2017 1:53 am
Location: NY

Re: Date Format Problem

Post by Tourless » Mon Jun 10, 2019 2:02 pm

Grovkillen wrote:
Thu Jun 06, 2019 8:04 pm

Code: Select all

GoSub>MONTHS_FIX

Month>MONTH_NUMBER
MidStr>1,1,TEST
If>TEST=0
MidStr>2,1,MONTH_NUMBER
EndIf>
Let>VERBOSE_MONTH_NAME=MONTH_NAME_%MONTH_NUMBER%

SRT>MONTHS_FIX
Let>RAW_LIST=January|February|March|April|May|June|July|August|September|October|November|December
Separate>RAW_LIST,|,MONTH_NAME
END>MONTHS_FIX 
Ahh, much cleaner, thank you very much!

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Date Format Problem

Post by JRL » Tue Jun 11, 2019 1:04 pm

Code: Select all

month>m
vbeval>monthname(%m%),vMoName
vbeval>monthname(%m%,true),vMoNameShort

User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Date Format Problem

Post by Grovkillen » Tue Jun 11, 2019 1:27 pm

Great JRL! I guess my example could be useful in generic ways of doing conversions while yours is great in this specific question.
Let>ME=%Script%

Running: 15.0.24
version history

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts