date issue
-
hi guys i want to get date values from my table in format like October-09 how can i do that ? regards.
Tauseef A Khan MCP Dotnet framework 2.0.
Tauseef A wrote:
i want to get date values from my table in format like October-09
Date values have no format, they are just numbers. It is only when they are displayed that you apply whatever format you want.
Tauseef A wrote:
MCP Dotnet framework 2.0.
:confused:
-
hi guys i want to get date values from my table in format like October-09 how can i do that ? regards.
Tauseef A Khan MCP Dotnet framework 2.0.
Tauseef A wrote:
i want to get date values from my table in format like October-09
You can use the below queries SELECT DATENAME(MM, GETDATE()) + ' ' + CAST(DAY(GETDATE()) AS VARCHAR(2)) AS [Month DD] SELECT REPLACE(RIGHT(CONVERT(VARCHAR(11), GETDATE(), 106), 8), ' ', '-') AS [Mon-YYYY] For more information kindly refer to link http://www.sql-server-helper.com/tips/date-formats.aspx[^]
Regards Aman Bhullar www.arlivesupport.com[^]
-
Tauseef A wrote:
i want to get date values from my table in format like October-09
You can use the below queries SELECT DATENAME(MM, GETDATE()) + ' ' + CAST(DAY(GETDATE()) AS VARCHAR(2)) AS [Month DD] SELECT REPLACE(RIGHT(CONVERT(VARCHAR(11), GETDATE(), 106), 8), ' ', '-') AS [Mon-YYYY] For more information kindly refer to link http://www.sql-server-helper.com/tips/date-formats.aspx[^]
Regards Aman Bhullar www.arlivesupport.com[^]
Aman Bhullar wrote:
SELECT DATENAME(MM, GETDATE()) + ' ' + CAST(DAY(GETDATE()) AS VARCHAR(2)) AS [Month DD] SELECT REPLACE(RIGHT(CONVERT(VARCHAR(11), GETDATE(), 106), 8), ' ', '-') AS [Mon-YYYY]
:confused: Neither of these give the OP what they asked for. The first gives "October 21" the second "Oct-2009"
-
hi guys i want to get date values from my table in format like October-09 how can i do that ? regards.
Tauseef A Khan MCP Dotnet framework 2.0.
On front end what tool are you using , try this might be helpful http://www.codeguru.com/csharp/csharp/cs_date_time/formatting/article.php/c4205/[^] http://blogs.msdn.com/kathykam/archive/2006/09/29/.NET-Format-String-102_3A00_-DateTime-Format-String.aspx[^] plus you did not went to US
Best Regards, SOFTDEV If you have knowledge, let others light their candles at it
-
Aman Bhullar wrote:
SELECT DATENAME(MM, GETDATE()) + ' ' + CAST(DAY(GETDATE()) AS VARCHAR(2)) AS [Month DD] SELECT REPLACE(RIGHT(CONVERT(VARCHAR(11), GETDATE(), 106), 8), ' ', '-') AS [Mon-YYYY]
:confused: Neither of these give the OP what they asked for. The first gives "October 21" the second "Oct-2009"
-
Try using SELECT DATENAME(MM, GETDATE()) + ' ' + RIGHT(CAST(YEAR(GETDATE()) AS VARCHAR(4)), 2) AS [Month YY] This will give the result in the desired format
Regards Aman Bhullar www.arlivesupport.com[^]
-
casting will make it slow
Best Regards, SOFTDEV If you have knowledge, let others light their candles at it