![]() | |
![]() |
| | Thread Tools | Display Modes |
#61
| |||
| |||
|
|
Howdy. I'm attempting to use DATEPART to give me a two-digit month, and further, to cast that as a nvarchar. It is rendering March as '3' instead of '03'. Is there a way to get '03' here???? Thanks. Danny |
#62
| |||
| |||
|
|
Howdy. I'm attempting to use DATEPART to give me a two-digit month, and further, to cast that as a nvarchar. It is rendering March as '3' instead of '03'. Is there a way to get '03' here???? Thanks. Danny |
#63
| |||
| |||
|
|
Howdy. I'm attempting to use DATEPART to give me a two-digit month, and further, to cast that as a nvarchar. It is rendering March as '3' instead of '03'. Is there a way to get '03' here???? Thanks. Danny |
#64
| |||
| |||
|
|
Howdy. I'm attempting to use DATEPART to give me a two-digit month, and further, to cast that as a nvarchar. It is rendering March as '3' instead of '03'. Is there a way to get '03' here???? Thanks. Danny |
#65
| |||
| |||
|
|
Howdy. I'm attempting to use DATEPART to give me a two-digit month, and further, to cast that as a nvarchar. It is rendering March as '3' instead of '03'. Is there a way to get '03' here???? Thanks. Danny |
#66
| |||
| |||
|
|
Howdy. I'm attempting to use DATEPART to give me a two-digit month, and further, to cast that as a nvarchar. It is rendering March as '3' instead of '03'. Is there a way to get '03' here???? Thanks. Danny |
#67
| |||
| |||
|
|
Howdy. I'm attempting to use DATEPART to give me a two-digit month, and further, to cast that as a nvarchar. It is rendering March as '3' instead of '03'. Is there a way to get '03' here???? Thanks. Danny |
#68
| ||||||||
| ||||||||
|
|
On Tuesday, June 10, 2008 3:23 PM Dann wrote: Howdy. I'm attempting to use DATEPART to give me a two-digit month, and further, to cast that as a nvarchar. It is rendering March as '3' instead of '03'. Is there a way to get '03' here???? Thanks. Danny |
|
On Tuesday, June 10, 2008 3:31 PM Tom Moreau wrote: Try: select replace (str (datepart (mm, getdate ()), 2), ' ', '0') -- Tom ---------------------------------------------------- Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS SQL Server MVP Toronto, ON Canada https://mvp.support.microsoft.com/profile/Tom.Moreau "Danny" <Danny (AT) discussions (DOT) microsoft.com> wrote in message news BD73AE0-D3A5-4747-A703-F9AE99B28633 (AT) microsoft (DOT) com...Howdy. I'm attempting to use DATEPART to give me a two-digit month, and further, to cast that as a nvarchar. It is rendering March as '3' instead of '03'. Is there a way to get '03' here???? Thanks. Danny |
|
On Tuesday, June 10, 2008 3:52 PM Aaron Bertrand [SQL Server MVP] wrote: SELECT RIGHT('0' + RTRIM(MONTH(GETDATE())), 2); |
|
On Tuesday, June 10, 2008 5:38 PM Dann wrote: yes, this works. Thank you Aaron. "Aaron Bertrand [SQL Server MVP]" wrote: |
|
On Wednesday, June 11, 2008 5:49 PM Gert-Jan Strik wrote: Yet another solution: SELECT SUBSTRING(CONVERT(nvarchar(6), CURRENT_TIMESTAMP, 112),5,2) -- Gert-Jan SQL Server MVP |
|
On Wednesday, June 11, 2008 6:05 PM Dann wrote: Thank you all for your help - greatly appreciated. "Danny" wrote: |
|
On Thursday, June 12, 2008 11:27 PM Alex Kuznetsov wrote: SELECT RIGHT(CAST(100 + MONTH(GetDate()) AS CHAR(3)),2) |
|
On Thursday, March 12, 2009 11:18 AM Ryan Tomlinson wrote: After looking at several solutions online, yours was by far the simplest and best. Thanks, Ryan |
#69
| |||||||||
| |||||||||
|
|
On Tuesday, June 10, 2008 3:23 PM Dann wrote: Howdy. I'm attempting to use DATEPART to give me a two-digit month, and further, to cast that as a nvarchar. It is rendering March as '3' instead of '03'. Is there a way to get '03' here???? Thanks. Danny |
|
On Tuesday, June 10, 2008 3:31 PM Tom Moreau wrote: Try: select replace (str (datepart (mm, getdate ()), 2), ' ', '0') -- Tom ---------------------------------------------------- Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS SQL Server MVP Toronto, ON Canada https://mvp.support.microsoft.com/profile/Tom.Moreau "Danny" <Danny (AT) discussions (DOT) microsoft.com> wrote in message news BD73AE0-D3A5-4747-A703-F9AE99B28633 (AT) microsoft (DOT) com...Howdy. I'm attempting to use DATEPART to give me a two-digit month, and further, to cast that as a nvarchar. It is rendering March as '3' instead of '03'. Is there a way to get '03' here???? Thanks. Danny |
|
On Tuesday, June 10, 2008 3:52 PM Aaron Bertrand [SQL Server MVP] wrote: SELECT RIGHT('0' + RTRIM(MONTH(GETDATE())), 2); |
|
On Tuesday, June 10, 2008 5:38 PM Dann wrote: yes, this works. Thank you Aaron. "Aaron Bertrand [SQL Server MVP]" wrote: |
|
On Wednesday, June 11, 2008 5:49 PM Gert-Jan Strik wrote: Yet another solution: SELECT SUBSTRING(CONVERT(nvarchar(6), CURRENT_TIMESTAMP, 112),5,2) -- Gert-Jan SQL Server MVP |
|
On Wednesday, June 11, 2008 6:05 PM Dann wrote: Thank you all for your help - greatly appreciated. "Danny" wrote: |
|
On Thursday, June 12, 2008 11:27 PM Alex Kuznetsov wrote: SELECT RIGHT(CAST(100 + MONTH(GetDate()) AS CHAR(3)),2) |
|
On Thursday, March 12, 2009 11:18 AM Ryan Tomlinson wrote: After looking at several solutions online, yours was by far the simplest and best. Thanks, Ryan |
|
On Friday, June 10, 2011 3:05 PM Amber Fontes wrote: Thank, Alex. I liked your solution and it worked great! |
![]() |
| Thread Tools | |
| Display Modes | |
| |