Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2011
    Posts
    184
    Thanks
    140
    Thanked 0 Times in 0 Posts

    Swtiching date formats of yyyy-mm-dd and dd/mm/yyyy to MS MDB format of mm/dd/yyyy

    Hello,

    I really need the help of the gurus/experts on this forum,

    I need your help.

    Using javascript, how can I detect which format the date is in and convert it to something that MS Access would be able to interpret and properly store?

    The function should transform the date from a date format of either yyyy-mm-dd and dd/mm/yyyy into
    mm/dd/yyyy

    How on earth does one do this? It seems impossible, because my users will enter in the date format that they grew up to, but the DB in the backend does not recognize the format as being valid, therefore I need the date into a mm/dd/yyyy format in order to write it back to the DB.

    Much thanks and appreciation for all your help and support.

    Cheers

    Jay

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,969
    Thanks
    56
    Thanked 557 Times in 554 Posts
    I see a lot of webpages using selects to avoid this problem:
    Code:
    <body>
    Day: <select id="day"></select>
    Month: <select id="month"></select>
    Year: <select id="year"></select>
    <script type="text/javascript">
    (function (){
    function fillSel(id, st, end){
    var optidx=0;
    for (var i = st; i < end; i++) {
    document.getElementById(id).options[optidx++]=new Option(i+1,i+1);
    }
    }
    fillSel("day",0,31);
    fillSel("month",0,12);
    fillSel("year",1900,2014);
    })();
    </script>
    
    </body>
    you would still need to validate if it is a "real" date

  • Users who have thanked xelawho for this post:

    jason_kelly (04-05-2014)

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Or use HTML5's <input type="date" /> to use the browser's built-in date control with datepicker. If the browser does not support it, then use xelawho's suggestion or use a datepicker plugin.

  • Users who have thanked glenngv for this post:

    jason_kelly (04-05-2014)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •