Normal Topic Last Month - Two Months Ago (Read 1124 times)
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Last Month - Two Months Ago
Jun 20th, 2013 at 2:31am
Print Post Print Post  
Hi all,

I'm still banging away at my stair step liquidation report, and I have a thought on how to do it with some hidden elements in a report.

However, the most simple thing is bogging me down -- the ability to determine values for "this month", "last month", and "two months ago". 

I've been putting hours into my retrieve, and it's not working-- can anyone help with some coding for this?
  
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Last Month - Two Months Ago
Reply #1 - Jun 20th, 2013 at 2:58pm
Print Post Print Post  
Hello Blair,

What type of retrieve spec? One on the form or one for XResultSetSearch()?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Re: Last Month - Two Months Ago
Reply #2 - Jun 20th, 2013 at 11:40pm
Print Post Print Post  
Hi Ray,

Here are my values set in the GLOBAL section of my report (a work in early progress).  I know it's doing to break against years, so that's what I could definitely use help on:

Code
Select All
stat vMonth0 as date
stat vMonth1 as date
stat vMonth2 as date
stat vOlder as date

vMonth0 = (@Str(@Year(@serverDate())) + "-" + (@Str(@month(@serverdate()))) + "=" + "01")
vMonth1 = (@Str(@Year(@serverDate())) + "-" + (@Str(@month(@serverdate())-1)) + "=" + "01")
vMonth2 = (@Str(@Year(@serverDate())) + "-" + (@Str(@month(@serverdate())-2)) + "=" + "01")

vOlder = (@Str(@Year(@serverDate())) + "-" + (@Str(@month(@serverdate())-2)) + "=" + "01")
 

  
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Last Month - Two Months Ago
Reply #3 - Jun 21st, 2013 at 1:53pm
Print Post Print Post  
Hello Blair,

Code
Select All
Function MonthsAgo(vMonths as Int) as Date
Var vFirstOfMonth as Date
Var vToday as Date
Var vLoop as Int

	vToday = @ServerDate()
	vFirstOfMonth = (vToday - @DOM(vToday)) + 1
	vLoop = 1
	While vLoop <= vMonths
	{
		vFirstOfMonth = vFirstOfMonth - 1 //Go to the last day of the previous month
		vFirstOfMonth = (vFirstOfMonth - @DOM(vFirstOfMonth)) + 1 //Go to first day of the previous month
		vLoop = vLoop + 1
	}

	Return(vFirstOfMonth)
End Function


Stat vMonth0 as Date
Stat vMonth1 as Date
Stat vMonth2 as Date
Stat vOlder as Date

vMonth0 = MonthsAgo(0)
vMonth1 = MonthsAgo(1)
vMonth2 = MonthsAgo(2)

vOlder = MonthsAgo(2) 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: Last Month - Two Months Ago
Reply #4 - Jun 21st, 2013 at 10:20pm
Print Post Print Post  
When I first started working with Sesame I decided to do a date calculator for calendaring. I wound up having to stop because of a conceptual problem:

We all agree that "a week before" June 8 is June 1, etc.

What date is "one month after January 31"? "One month before March 30"?

Undecided I never could figure out how to code "... uh ..."

The bottom line is that there is no agreement. You can't simply code an arbitrary decision.  However you define "one month" in those situations, various users will interpret "one month" differently--and then you'll wind up with inconsistencies, resulting in missed deadlines, parts ordered or products shipped early, etc.

Of course, there is also the risk that at some point in the future one of the bigwigs will insist, "That's not what 'one month' is! From now on, here's how we're gonna do it! ..." And then you wind up with search criteria scattered all over the place that have to be found and rewritten.
  
Back to top
 
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: Last Month - Two Months Ago
Reply #5 - Jun 21st, 2013 at 10:23pm
Print Post Print Post  
And, of course, there is the person who decides without thinking "Obviously, one month before May 31 is April 31!" and enters that (assuming, of course, it's some kind of text field rather than a date field that won't accept invalid dates).

Kinda like miniature Y2K's ...
  
Back to top
 
IP Logged
 
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Re: Last Month - Two Months Ago
Reply #6 - Jun 22nd, 2013 at 3:26pm
Print Post Print Post  
That worked like a charm!  Thanks Ray!
  
Back to top
IP Logged