|
Jbalbo
Starting Member
5 Posts |
Posted - 02/14/2013 : 16:56:46
|
I have the following formula from a crystal report.. Looking to see if its possible to create a daysdif in SQL ..
First part calculated which date to use as a start date depending on the criteria of the if's it decides which date to use
Second part cals which to use for the end date
Then it writes out the daysdif in days beween start and end dates
I was thinking I could come up witha daysdiff which a bunch of if's in it?
Thanks
// Local Datevar Start; Local Datevar End;
If (cdate({APPOINTMENT.EffDate}) <= {?date}-27 And cdate({APPOINTMENT.Expdate}) in {?date}-27 to {?date}-21) Then Start:={?date}-28 else if (cdate({APPOINTMENT.EffDate}) < {?date}-27 and cdate({APPOINTMENT.Expdate})> {?date}-21) then start:={?date}-28 else if (cdate({APPOINTMENT.EffDate}) in {?date}-27 to {?date}-21) then start:=cdate({APPOINTMENT.EffDate}-1) ;
// end
If ({APPOINTMENT.EffDate} <= {?date}-27 And {APPOINTMENT.Expdate} in {?date}-27 to {?date}-21) Then End:=cdate({APPOINTMENT.Expdate}) else if ({APPOINTMENT.EffDate} < {?date}-27 and {APPOINTMENT.Expdate}> {?date}-21) then end:={?date}-21 else if (cdate({APPOINTMENT.EffDate}) in {?date}-27 to {?date}-21 and cdate({APPOINTMENT.Expdate}) > {?date}-21)then end:={?date}-21;
//tart:=end
Datediff("d",Start, End)
Thanks
|
|