Results 1 to 4 of 4
  1. #1
    uthpalaw is offline Member
    Join Date
    Mar 2010
    Posts
    68
    Rep Power
    0

    Default how to remove milliseconds

    Hi,

    I have a datetime data type column which stores date and the time with milliseconds. Is there any sql query to select the date and time without milliseconds ?

    for exa : suppose i have this value - 2011-02-24 08:52:26,610

    when i run the select query i need 2011-02-24 08:52:26 (without milliseconds)

    Thanks,
    Uthpala

  2. #2
    lovelesh is offline Senior Member
    Join Date
    Nov 2010
    Location
    Delhi
    Posts
    135
    Blog Entries
    1
    Rep Power
    0

    Smile

    you can specify the format of timestamp in select query.

    use DATE_FORMAT function in MYSQL
    use to_timestamp function in Oracle

  3. #3
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Quote Originally Posted by lovelesh View Post
    use to_timestamp function in Oracle
    I believe you mean to_char. ;-)

    You use to_timestamp to create a timestamp from text.

  4. #4
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default

    If this is simply for display purposes I'd take the datetime in the select and simply use a SimpleDateFormat for display. That way you have no db-specific SQL in your code.

Similar Threads

  1. Remove .0
    By maple_leafs182 in forum New To Java
    Replies: 4
    Last Post: 01-28-2011, 02:47 AM
  2. how to get milliseconds out of it
    By baktha.thalapathy in forum New To Java
    Replies: 2
    Last Post: 06-06-2010, 01:57 PM
  3. Convert string hh:mm to milliseconds
    By sm123 in forum New To Java
    Replies: 2
    Last Post: 03-11-2010, 12:29 PM
  4. how to remove this error
    By ravinder64 in forum Java Servlet
    Replies: 1
    Last Post: 11-01-2008, 07:04 AM

Posting Permissions

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