Date Format

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a DATATIME field that I must display in the MM/DD/YYYY format. The
DATETIME field stores the Date and Time, and that's how I want it. But in my
Stored Procedure and Views I want to only display the Date Portion.

So, I want the value of "10/11/2006 10:20:00" to be displayed as
"10/11/2006" only.

I've tried FORMAT(MyDate,'mm/dd/yyyy'), but I get an error. Plus, I can't
find this in the documentation. I must be looking this stuff up wrong. I did
a search on "FORMAT DATE" and hove found nothing helpful.

Thanks for your help.
 
Hello,

I understand that you'd like to use function/SP to display datetime field
as "MM/DD/YYYY" format. If it is not correct, please let me know.

If its left in a datetime data type, the time portion will always be
returned. However, you could convert it to a string using something like
the following,

select convert(varchar(10), getdate(), 101)

Please see the following article for more details:

CAST and CONVERT
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_
ca-co_2f3o.asp

If anything is unclear or you have any concerns, please feel free to let's
know. Thank you.

Best Regards,

Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications
<http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx>.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
<http://msdn.microsoft.com/subscriptions/support/default.aspx>.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top