Hello can someone please give me the correct format in my SQL Query to get my Date and Time in the correct
format. For date all I want is MM/DD/YYYY and form time without the 1/1/1900 the time in HH:MM format.
Thanks
To select Date in mm/dd/yyyy format use style 101:
Select convert(char(10), dateval, 101) As DateOnly
To select Time only in hh:mm:ss format use style 8 or 108:
Select convert(char(8), dateval, 8) As TimeOnly
For more information on date/time styles see "Cast and Convert" in SQL Books Online. Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it if you have time.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.