on 08-11-2015 5:24 PM
Hi
On the given date, How to find the start date of previous month and end date of the previous month of the given date.
For Example I have given the date 20-12-2014 as input , then I have to get previous month start date as '01-11-2013' and end of the previous month '30-11-2013' , Please anybody can help me with proper logic to get the solution.
Regards
Pol
Hi Polachan;
I would recommend having a look at the DaysAfter ( ) and RelativeDate ( ) PB methods to help you in this endevour.
Regards ... Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here's a shorter one:
date ld,ld_first,ld_last
em_date.getdata(ld)
ld_last = relativedate(ld,-day(ld))
ld_first = date(year(ld_last),month(ld_last),1)
messagebox(string(ld),string(ld_first)+', '+string(ld_last))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please try as follow,
Date ldt_in_date
Long ll_y , ll_m
// Input date.. I use Today() as input date..
ldt_in_date = Today()
ll_y = Year (ldt_in_date)
ll_m = Month(ldt_in_date)
IF ll_m = 1 THEN
ll_m = 12
ll_y --
ELSE
ll_m --
END IF
MessageBox( "Last Month Start date" , String( Date(ll_y, ll_m, 1) ) )
MessageBox("Last Month End date" , String( RelativeDate(Date(Year(ldt_in_date), Month(ldt_in_date), 1), -1)))
Regards,
Jahir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The easiest way to get the last day of a month is to do a RelativeDate passing the first of the following month as the date and -1 as the number of days.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.