Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Range

Status
Not open for further replies.

smmt2207

MIS
Feb 27, 2007
36
0
0
US
Does anyone know of a formula that would break out a date range.
For example:

Current field is 04/01/10-04/15/10

I would like to see
04/01/10
04/02/10
04/03/10
04/04/10
04/05/10

Any help would be greatly appreciated.
 
This should give you just the first/start date:
//{@SplitonHyphen1}
Split({YourTable.YourFieldName},"-")[Ubound{Split({YourTable.YourFIeldName},"-"))-1]

This should give you just the second/end date
//{@SplitonHyphen2}
Split({YourTable.YourFieldName},"-")[Ubound{Split({YourTable.YourFIeldName},"-"))]


If the month's are always going to be the same, you could try this for the days in between ---->This is untested so i apologize in advance if my memory (or lack thereof) has caused errors:

//{@StartDayNumber}
shared numbervar ds1 := instr({@SplitonHyphen1},"/");
mid({@SplitonHyphen1},ds1+1,2)

//{@EndDayNumber}
shared numbervar ds2 := instr({SplitonHyphen2},"/");
mid({@SplitonHyphen2},ds2+1,2)

//{@DatesBetween}
shared numbervar ds1;
shared numbervar ds2;
datevar i;
numbervar dy := year({@SplitonHyphen1});
numbervar dm := month({@SplitonHyphen1});
numbervar dd := ds1;

For dd := ds1 to ds2
Do (
i := dm&"/"&dd+1&"/"&dy);
i

 



FYI,

A Field containg data like 04/01/10-04/15/10 is an absolutely horrible design. The creator ought to be publicly drawn and quartered, IMHO!

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Skip....i agree 100%!!! kinda defeats the purpose of a database to store info like that!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top