question

technette avatar image
technette asked

Convert to Date formate MM/DD/YYYY

Hi! How do I convert the following to date format of MM/DD/YYYY Right now this is adding the count frequency in days to the last count date and when I try to convert to varchar date format 102, I still get datetime format like 12/13/2015 12:00:00 AM DATEADD(d, C.COUNT_FREQ, C.LAST_COUNT_DATE)as NEXT_DATE
date-format
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

JohnM avatar image JohnM commented ·
Why can't you just cast it as a DATE? This would effectively return just the date component. IE: CAST(DATEADD(d,c.count_freq,c.last_count_date) as DATE) as NEXT_DATE
1 Like 1 ·
technette avatar image technette commented ·
This is SQL 2005 the CAST doesn't work
0 Likes 0 ·

1 Answer

·
KenJ avatar image
KenJ answered
It would help if you provided your whole statement - we can only imagine what might be right or wrong with the convert statement. As an example, the following uses convert ([ https://msdn.microsoft.com/en-us/library/ms187928.aspx][1]) and style 101 with a hard-coded LAST_COUNT_DATE and COUNT_FREQ: select convert(varchar, DATEADD(d, 2, '2015-03-04'), 101) as NEXT_DATE It returns `'03/06/2015'` [1]: https://msdn.microsoft.com/en-us/library/ms187928.aspx
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.