cancel
Showing results for 
Search instead for 
Did you mean: 

default value for date

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hey Navneet....

Thank you so much...but if my now date is the first day of the month how does this work..

eg now date is 01.08.2007

thanks in advance.....:)

Regards,

Bijal

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

It's simple to test.

I hope you have admin access, Please change the system date to 1st Sep and check.

Regards

Navneet

Former Member
0 Kudos

Hie..

i dont have admin rights, any other way?

And also let me know y isnt dval working .. its giving some starnge date..

Thanks

Bijal

Former Member
0 Kudos

I am sure about solution i have provided...as i have tested it.

I am sorry but i guess you gotta either get the sys date changed or wait until 01 Sep.....;-)

About the other query,i have no idea as to why it is giving strange data... may be you could raise it as a new thread.

Regards

Navneet

Answers (1)

Answers (1)

Former Member
0 Kudos

hi

on your Date_from field , enter this formula DADD(now(),-3,"M")

I hope this will solve your problem

Thanks & Regards

Harsimran