on 08-27-2007 6:54 AM
Hi experts,
I want to set default value for dates..
My screen has : date_from & date_to.
date_to : will be current date(today's date) if Eg: 27.08.2007 (here i used NOW())
then date_from must be 01.06.2007 (3 months logic)
similarly : if date_to is 01.01.2007
then date_from must be 01.11.2006
kindly help...
Thanks a lot!!!
Regards,
Bijal
hi
perfect answer to your requirement ,jus put this to your formula :-
DADD(DADD(NOW(),-((DGET(NOW(),'D'))-1),'D'),-2,'M')
This will give you Jun 1 2007 , current date: 27 Aug,2007
Message was edited by:
Navneet Giria
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bijal
This will work for even 01.08.2007 but the date you'll get will be 01.06.2007.
I think if you are looking at displaying 01.05.2007, in that case you have put a IF condition for 1st Date of the month in the formula using conditional operators.
Roughly, IF DGET(NOW(),'D')=1
THEN
DADD(NOW(),-3,'M')
ELSE
DADD(DADD(NOW(),-((DGET(NOW(),'D'))-1),'D'),-2,'M')
Try it with proper syntax of IF in VC.
Regards
Navneet
Hello navneet
This will work for even 01.08.2007 but the date you'll get will be 01.06.2007.?? how do u say this works, since in the formula u gave me, u subtracted 1 from now day..
(DGET(NOW(),'D'))-1) ..... here it will go back in last month....
i tried this , it give me error...expected date/value expression....
IF(DGET(NOW(),'D')!=1,DADD(DADD(NOW(),-((DGET(NOW(),'D'))-1),'D'),-2,'M'),DADD(NOW(),-2,'M'))
thanks for ur guidance again...
Bijal
Hi Bijal
(DGET(NOW(),'D'))-1) returns number which is 0 incase of 01.08.2007, so DADD(NOW(),-0,'D') is again ideally same day 01.08.2007 .
So, DADD(DADD(NOW(),-0,'D'),-2,'M') should give you 01.06.2007.
<b> IT WORKS!!! -
I have tested it now.</b>
Please check and revert.
The IF formula which sent actually returns String, so use DVAL(IF(DGET(NOW(),'D')!=1,DADD(DADD(NOW(),-((DGET(NOW(),'D'))-1),'D'),-2,'M'),DADD(NOW(),-2,'M')))
Message was edited by:
Navneet Giria
Hie Navneet....
Thanks again... U have been really very helpful...
WITH DVAL... DATE_FROM calculated is JAN 06,2007... strange not JUN 01,2007...
The IF formula which i sent actually returns String, so use DVAL(IF(DGET(NOW(),'D')!=1,DADD(DADD(NOW(),-((DGET(NOW(),'D'))-1),'D'),-2,'M'),DADD(NOW(),-2,'M')))
Trust u that DADD(DADD(NOW(),-((DGET(NOW(),'D'))-1),'D'),-2,'M') wud work, but how do i test that since now date i cannot change...
Regards,
Bijal
hi
on your Date_from field , enter this formula DADD(now(),-3,"M")
I hope this will solve your problem
Thanks & Regards
Harsimran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.