Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2005
    Posts
    119

    Unanswered: SQL Query Syntax to format date fields

    Hi! Good Day!

    What is the syntax to format the datefield? The value of my datefield is like this:

    10/13/2005 5:15:02 PM

    What is the select query to filter the date only. My desired result should be:

    10/13/2005

    only.

    Thanks

  2. #2
    Join Date
    Oct 2004
    Location
    In cousin's house
    Posts
    303
    ok try dis
    Code:
    select  field1,convert(varchar,fielddate,101) from tablename

  3. #3
    Join Date
    Oct 2005
    Posts
    119
    Thanks.
    I was now able to get the date only.

    How about if i wanted to get the time only.
    For example for this value "10/13/2005 5:15:02 PM".
    My desired result would be: "5:15:02 PM".

    Thanks for taking the time to anwer my questions.

    God bless

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    Check out Convert in BOL - it has a table of all the possible datetime conversions you could think of
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Feb 2004
    Location
    Bangalore, India
    Posts
    250
    hi

    try this

    SELECT CONVERT(VARCHAR,datetimefield,108) FROM table
    Cheers....

    baburajv

  6. #6
    Join Date
    Oct 2005
    Posts
    119
    Thank you so much guys.
    My query is ok now.
    God bless.

Posting Permissions

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