Page 1 of 1 1
Topic Options
#122326 - 2004-07-07 11:43 PM Is there an easier way to do this?
Fugazi Offline
Starting to like KiXtart

Registered: 2001-04-23
Posts: 142
Loc: Pace, Fl.
I am trying to come up with a formula to take todays date and subtract 1 day from the final date stamp. I need to have the final output in MM/DD/YYYY format which will then be written to an INI file.

$month = @MONTHNO
$day = @MDAYNO -1
$year = @YEAR
If $month < 10
$month = "0@MONTHNO"
EndIf
If $day < 10
$dayminus1=@MDAYNO - 1
$day = "0$dayminus1"
EndIf
If @MDAYNO = 1
Select
Case @MONTHNO = "1"
$month = "12"
$day = "31"
$year = @YEAR - 1
Case @MONTHNO = "2"
$month = "01"
$day = "30"
Case @MONTHNO = "3"
$month = "02"
$day = "28"
If @YEAR = "2008"
$day = "29"
EndIf
Case @MONTHNO = "4"
$month = "03"
$day = "31"
Case @MONTHNO = "5"
$month = "04"
$day = "30"
Case @MONTHNO = "6"
$month = "05"
$day = "31"
Case @MONTHNO = "7"
$month = "06"
$day = "30"
Case @MONTHNO = "8"
$month = "07"
$day = "31"
Case @MONTHNO = "9"
$month = "08"
$day = "31"
Case @MONTHNO = "10"
$month = "09"
$day = "30"
Case @MONTHNO = "11"
$month = "10"
$day = "31"
Case @MONTHNO = "12"
$month = "11"
$day = "30"
EndSelect
EndIf
$date="$month/$day/$year"
_________________________
I haven't failed. I just found another way that did not work.

Top
#122327 - 2004-07-07 11:57 PM Re: Is there an easier way to do this?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Yes

DateCalc(@date,-1)

Only prob is the DateCalc() UDF returns YYYY/MM/DD.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#122328 - 2004-07-08 12:04 AM Re: Is there an easier way to do this?
Fugazi Offline
Starting to like KiXtart

Registered: 2001-04-23
Posts: 142
Loc: Pace, Fl.
Were can I get the DateCalc UDF?
_________________________
I haven't failed. I just found another way that did not work.

Top
#122329 - 2004-07-08 12:05 AM Re: Is there an easier way to do this?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
In our UDF library.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#122330 - 2004-07-08 12:14 AM Re: Is there an easier way to do this?
Fugazi Offline
Starting to like KiXtart

Registered: 2001-04-23
Posts: 142
Loc: Pace, Fl.
I did a search for DateCalc and only return this post.

I could take the output of the DateCalc and add

$year=Trim(Split(DateCalcOutput,"\")[0])
$month=Trim(Split(DateCalcOutput,"\")[1])
$day=Trim(Split(DateCalcOutput,"\")[2])

and rearrange the output.

_________________________
I haven't failed. I just found another way that did not work.

Top
#122331 - 2004-07-08 12:18 AM Re: Is there an easier way to do this?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You must not have done it right. There is a FAQ on how to search.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#122332 - 2004-07-08 12:21 AM Re: Is there an easier way to do this?
Fugazi Offline
Starting to like KiXtart

Registered: 2001-04-23
Posts: 142
Loc: Pace, Fl.
Duh, Dummy me. Did the same thing I do everytime forgot to change the date range.

Thanks
_________________________
I haven't failed. I just found another way that did not work.

Top
#122333 - 2004-07-08 12:25 AM Re: Is there an easier way to do this?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Common mistake.

No need to Trim() and Split() 3 times.

$=Split(@date,'/')
$Date=$[2]+'/'+$[1]+'/'+$[0]
$Date
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.062 seconds in which 0.029 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