get first of current month

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
sks17
Newbie
Posts: 2
Joined: Tue Jun 21, 2011 3:03 pm

get first of current month

Post by sks17 » Tue Jun 21, 2011 3:10 pm

I need some scripting help! I am looking to get the first of the current month, format (mm/dd/yy) and send the text to my program field. I then need to get the current date minus one day, format (mm/dd/yy) and send that text to my field. I am pretty new at this, and this has got me stuck. Any help would be great!!
Shannon

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

Post by JRL » Tue Jun 21, 2011 4:09 pm

Here's examples for getting the dates

Code: Select all

//get date compnents
Day>dd
Month>mm
Year>yyyy

//make 2 digit year
Midstr>yyyy,3,2,yy

//First of month
Let>FirstOfCurrentMonth=%mm%/01/%yy%

//Today
Let>Today=%mm%/%dd%/%yy%


//There's probably a one line vbscript to do the following.
//This is what I know how to do.

//Today minus one but not the proper format
Sub>Today,1

//fix the date format
Separate>today,/,item
Length>item_1,len
If>len=1
  Let>Item_1=0%item_1%
EndIf

Length>item_2,len
If>len=1
  Let>Item_2=0%item_2%
EndIf

Length>item_3,len
If>len=4
  Midstr>Item_3,3,2,Item_3
EndIf

//put the formated components back together
Let>TodayMinusOne=%Item_1%/%item_2%/%item_3%


MDL>FirstOfCurrentMonth = %FirstOfCurrentMonth%%CRLF%TodayMinusOne = %TodayMinusOne%

sks17
Newbie
Posts: 2
Joined: Tue Jun 21, 2011 3:03 pm

Post by sks17 » Tue Jun 21, 2011 4:49 pm

Thank you very much. This helps!
Shannon

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