Hi all,

I need a date string containing the 1st day of the current
month.

IE:
? lcDate
07/01/03

or the a date string containing the last day of the
previous month.

? lcDate
06/30/03

Your input is appreciated. Thanks.

Re: date question by Ken

Ken
Thu Jul 31 20:48:50 CDT 2003

Try these:

? CFOTM()
? CLOLM()
? CFOTM("day")
? CLOLM("day")
? CFOTM("day","2/23/1986")
? CLOLM("day","2/23/1986")

FUNCTION CFOTM()
LPARAMETERS returntype, seeddate

IF NOT EMPTY(returntype)
DO CASE
CASE TYPE("returntype") <> "C"
MESSAGEBOX("Data type mismatch.")

RETURN
CASE NOT UPPER(ALLTRIM(returntype)) == "DAY" AND ;
NOT UPPER(ALLTRIM(returntype)) == "DATE"
MESSAGEBOX("Invalid return type.")

RETURN
ENDCASE
ELSE
returntype = "DATE"
ENDIF

IF NOT EMPTY(seeddate)
DO CASE
CASE TYPE("seeddate") = "C"
seeddate = CTOD(seeddate)
CASE TYPE("seeddate") = "D"
OTHERWISE
MESSAGEBOX("Invalid parameter.")

RETURN
ENDCASE
ELSE
seeddate = DATE()
ENDIF

cFirstDate = TRANSFORM(MONTH(seeddate)) + "/1/" + ;
TRANSFORM(YEAR(seeddate))

IF UPPER(ALLTRIM(returntype)) == "DAY"
cFirstDate = CDOW(CTOD(cFirstDate))
ENDIF

RETURN cFirstDate
ENDFUNC

FUNCTION CLOLM()
LPARAMETERS returntype, seeddate

IF NOT EMPTY(returntype)
DO CASE
CASE TYPE("returntype") <> "C"
MESSAGEBOX("Data type mismatch.")

RETURN
CASE NOT UPPER(ALLTRIM(returntype)) == "DAY" AND ;
NOT UPPER(ALLTRIM(returntype)) == "DATE"
MESSAGEBOX("Invalid return type.")

RETURN
ENDCASE
ELSE
returntype = "DATE"
ENDIF

IF NOT EMPTY(seeddate)
DO CASE
CASE TYPE("seeddate") = "C"
seeddate = CTOD(seeddate)
CASE TYPE("seeddate") = "D"
OTHERWISE
MESSAGEBOX("Invalid parameter.")

RETURN
ENDCASE
ELSE
seeddate = DATE()
ENDIF

cFirstThisMonth = TRANSFORM(MONTH(seeddate)) + "/1/" + ;
TRANSFORM(YEAR(seeddate))

cLastDate = TRANSFORM(CTOD(cFirstThisMonth) - 1)

IF UPPER(ALLTRIM(returntype)) == "DAY"
cLastDate = CDOW(CTOD(cLastDate))
ENDIF

RETURN cLastDate
ENDFUNC

HTH,

Ken Dibble
Southern Tier Independence Center

On Thu, 31 Jul 2003 15:41:15 -0700, "Jack" <_@_.com> wrote:

>Hi all,
>
>I need a date string containing the 1st day of the current
>month.
>
>IE:
>? lcDate
>07/01/03
>
>or the a date string containing the last day of the
>previous month.
>
>? lcDate
>06/30/03
>
>Your input is appreciated. Thanks.


Re: date question by trw7atixdotnetcomdotcom

trw7atixdotnetcomdotcom
Fri Aug 01 11:04:30 CDT 2003

Jack seemed to utter in news:05a501c357b4$d99cd650$a301280a@phx.gbl:

> Hi all,
>
> I need a date string containing the 1st day of the current
> month.
>
> IE:
> ? lcDate
> 07/01/03
>
> or the a date string containing the last day of the
> previous month.
>
> ? lcDate
> 06/30/03
>
> Your input is appreciated. Thanks.
>

FUNCTION FirstOfCurrent

RETURN DTOC(DATE(YEAR(DATE()), MONTH(DATE()), 1))

FUNCTION LastOfPrior

RETURN DTOC(DATE(YEAR(DATE()), MONTH(DATE()), 1) - 1)

-- TRW
_______________________________________
My e-mail: t r w 7
@ i x . n e t c o m . c o m
_______________________________________

date question by Steve

Steve
Fri Aug 01 11:02:36 CDT 2003

dDate is variable or parameter

First Day of Month: (dDate+1-DAY(dDate))

Last Day of Month: GOMONTH(dDate+1-DAY(dDate),1)-1


>-----Original Message-----
>Hi all,
>
>I need a date string containing the 1st day of the
current
>month.
>
>IE:
>? lcDate
>07/01/03
>
>or the a date string containing the last day of the
>previous month.
>
>? lcDate
>06/30/03
>
>Your input is appreciated. Thanks.
>
>.
>