converting datetime to date

Posted on 2012-08-22
Last Modified: 2013-01-25
I need to convert datetime to date using javascript, any suggestions would be appreciated.
Question by:Mike Johnson
    LVL 25

    Expert Comment

    Not sure I understand. A JavaScript date object has a time component.  Are you trying to convert a string into a date object?

    Please provide an example.
    LVL 7

    Assisted Solution

    You could use:
    myDateParts = myDate.split("/");
    myJSDate = new Date(myDateParts[2], myDateParts[1], myDateParts[0]);

    Or it would be easier if you are getting it from a SQL database to make the conversion there?
    LVL 75

    Expert Comment

    by:Michel Plungjan
    Next time please provide input and expected output in your question
    LVL 41

    Expert Comment

    Might this article be of any assistance?
    LVL 76

    Accepted Solution

    >>Or it would be easier if you are getting it from a SQL database to make the conversion there?


    Since this was posted in an Oracle zone I have to assume an Oracle database.  In Oracle dates have an internal format.  They can be displayed however you want when selected and converted into strings.

    select to_char(some_date_column,'MM/DD/YYYY'),
      to_char(some_date_column,'MM/DD/YYYY  HH24:MI:SS'),
      to_char(some_date_column,'MM/DD/YYYY HH:MI:SS AM')
    from table;

    The formats are pretty much endless:
    LVL 53

    Expert Comment

    This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
    From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
    The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now