Date Interval Functions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lynn

    Date Interval Functions

    On a form I have

    Date_Start Date_End

    I have a new
    Date_Start1 Date_End1 which the use
    inputs.

    I need to validate that Date_Start1 and Date_End1 are a date range
    entirely separate from Date_Start and Date_End i.e. no overlapping
    whatsoever. In effect checking a date interval.

    Are there any functions out there already written that can do this? It
    seems to basic to start comparing and contracting dates! Would like to
    do it in Javascript, but happy in vbscript also.

    Thanks,
    Lynn
  • Dr John Stockton

    #2
    Re: Date Interval Functions

    JRS: In article <1d9192b3.04021 60906.7d58b979@ posting.google. com>, seen
    in news:comp.lang. javascript, Lynn <runningwiththe wolves@hotmail. com>
    posted at Mon, 16 Feb 2004 09:06:17 :-[color=blue]
    >On a form I have
    >
    >Date_Start Date_End
    >
    >I have a new
    >Date_Start1 Date_End1 which the use
    >inputs.
    >
    >I need to validate that Date_Start1 and Date_End1 are a date range
    >entirely separate from Date_Start and Date_End i.e. no overlapping
    >whatsoever. In effect checking a date interval.[/color]

    Firstly validate the dates and convert them to Date Objects.
    Check that Start < End and Start1 < End1.
    Check that End < Start1 or End1 < Start.
    That can be done by direct comparison of Objects.



    If your dates are in the sensible International Standard form, then it
    is not necessary to use Date Objects; just compare strings in YYYYMMDD
    YYYY-MM-DD or YYYY/MM/DD forms.

    If your dates are in numeric form without leading zero, e.g. 23/4/1564
    or 23/4/1616, you can use a RegExp to remedy that.

    If your dates lack, or may lack, the upper two digits of the year, you
    can use a RegExp to remedy that.

    If your dates are in a known non-standard order, you can use a RegExp to
    remedy that.

    [color=blue]
    >Are there any functions out there already written that can do this? It
    >seems to basic to start comparing and contracting dates! Would like to
    >do it in Javascript, but happy in vbscript also.[/color]

    See below.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
    <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
    <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demo n.co.uk/vb-dates.htm> VB maths, dates, sources.

    Comment

    Working...