Friday, February 24, 2012

Format Date

I have a stored procedure that selects several fields from a table,
including a date field. I'd like to format the date field in the stored
proc so that the result reads mmddyy or mmddyyyy - without any slashes
or dashes, and without the time (06/26/2006 06:53:06.373 would read
06262006). Any ideas?4 digit year
Select Replace(Convert(varchar(10), GetDate(), 101), '/', '')
2 digit year
Select Replace(Convert(varchar(10), GetDate(), 1), '/', '')
Tom
<birdbyte@.gmail.com> wrote in message
news:1151335825.434174.81350@.i40g2000cwc.googlegroups.com...
>I have a stored procedure that selects several fields from a table,
> including a date field. I'd like to format the date field in the stored
> proc so that the result reads mmddyy or mmddyyyy - without any slashes
> or dashes, and without the time (06/26/2006 06:53:06.373 would read
> 06262006). Any ideas?
>|||How handy! Worked like a charm! Thanks!
Tom Cooper wrote:
> 4 digit year
> Select Replace(Convert(varchar(10), GetDate(), 101), '/', '')
> 2 digit year
> Select Replace(Convert(varchar(10), GetDate(), 1), '/', '')
> Tom
> <birdbyte@.gmail.com> wrote in message
> news:1151335825.434174.81350@.i40g2000cwc.googlegroups.com...

No comments:

Post a Comment