Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FORMATTING DATE IN STORED PROC

Status
Not open for further replies.

SeanB

Programmer
Jul 19, 2001
70
US
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
 

You need to use th CONVERT function.

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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top