Page 1 of 1 1
Topic Options
#6713 - 2001-02-06 09:15 PM How to subtract a month?
Anonymous
Unregistered


I'm running a report that records data for the previous month. I have broken down the date all ready but can't get it to read the month before..


$DAY=SUBSTR("@DATE",9,2)
$MONTH=SUBSTR("@DATE",6,2)
$YEAR=SUBSTR("@DATE",1,4
02/01/2001
I need 01/01/2001

Can the month be subtracted with a value?

Help


Top
#6714 - 2001-02-06 09:21 PM Re: How to subtract a month?
Paul_Berquam Offline
Hey THIS is FUN

Registered: 2000-08-02
Posts: 310
Loc: Sacramento, CA USA
Is this what you're looking for?

code:

$DAY=SUBSTR("@DATE",9,2)
$MONTH=SUBSTR("@DATE",6,2)
$YEAR=SUBSTR("@DATE",1,4)
$lastmonth = val($month) - 1

? "Day is $day"
? "Month is $month"
? "Year is $year"

? ? "Last month is $lastmonth"
? ? "Paused"
get $c


[This message has been edited by Paul_Berquam (edited 06 February 2001).]

_________________________
He was a good little monkey and always very curious...

Top
#6715 - 2001-02-06 09:36 PM Re: How to subtract a month?
Anonymous
Unregistered


That's IT

Thanks

Top
#6716 - 2001-02-07 08:26 AM Re: How to subtract a month?
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
be aware of January :
code:

$DAY=SUBSTR("@DATE",9,2)
$MONTH=SUBSTR("@DATE",6,2)
$YEAR=SUBSTR("@DATE",1,4)
IF $MONTH = "01"
$lastmonth = "12"
$YEAR = val($YEAR) - 1
ELSE
$lastmonth = val($MONTH) - 1
IF $lastmonth < 10 $lastmonth = "0" + $lastmonth ENDIF
ENDIF

? "Day is $day"
? "Month is $month"
? "Year is $year"

? ? "Last month is $lastmonth/$YEAR"
? ? "Paused"
get $c


J.

_________________________



Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 957 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.054 seconds in which 0.028 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org