Unanswered: Return formatted date from stored proc?
What is the recommended method of returning a formatted date from a stored procedure?
The date is held in a date time field. I wish to return the date formatted as:
for display in a bound text box on a win form. JUst selecting the date and binding it to the text box shows:
I do not want the :ss to show. A textbox does not have a format property (that I can see). I suppose I could create my own textbox inheriting from the standard and apply a display format property. I thought it may be easier to select as required in an sp. The textbox is read only on the form.
I was looking at:
select jobHeaders.DateTimeJobTaken AS [Job Taken],
CAST(datepart(dd,jobHeaders.DateTimeJobTaken) as char(2)) + '/' +
CAST(datepart(mm,jobHeaders.DateTimeJobTaken) as char(2)) + '/' +
CAST(datepart(yyyy,jobHeaders.DateTimeJobTaken) as char(4))
but this gives :
8 /3 /2004 with spaces.
Before looking further I thought one of you guys may have the answer.
Hmmmm, Sorry, but I am not wrong. The statement above pertains to converting FROM datetime TO anything other than the data types mentioned. Your example demonstrates the usage of the 3rd parameter in conversion FROM varchar TO datetime, where the 3rd parameter actually plays an important part.