dbTalk Databases Forums  

How to get a two-digit month value

microsoft.public.sqlserver.server microsoft.public.sqlserver.server


Discuss How to get a two-digit month value in the microsoft.public.sqlserver.server forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Danny
 
Posts: n/a

Default How to get a two-digit month value - 06-10-2008 , 02:23 PM






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

Reply With Quote
  #2  
Old   
Tom Moreau
 
Posts: n/a

Default Re: How to get a two-digit month value - 06-10-2008 , 02:31 PM






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

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



Reply With Quote
  #3  
Old   
Tom Moreau
 
Posts: n/a

Default Re: How to get a two-digit month value - 06-10-2008 , 02:31 PM



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

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



Reply With Quote
  #4  
Old   
Tom Moreau
 
Posts: n/a

Default Re: How to get a two-digit month value - 06-10-2008 , 02:31 PM



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

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



Reply With Quote
  #5  
Old   
Tom Moreau
 
Posts: n/a

Default Re: How to get a two-digit month value - 06-10-2008 , 02:31 PM



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

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



Reply With Quote
  #6  
Old   
Tom Moreau
 
Posts: n/a

Default Re: How to get a two-digit month value - 06-10-2008 , 02:31 PM



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

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



Reply With Quote
  #7  
Old   
Tom Moreau
 
Posts: n/a

Default Re: How to get a two-digit month value - 06-10-2008 , 02:31 PM



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

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



Reply With Quote
  #8  
Old   
Tom Moreau
 
Posts: n/a

Default Re: How to get a two-digit month value - 06-10-2008 , 02:31 PM



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

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



Reply With Quote
  #9  
Old   
Tom Moreau
 
Posts: n/a

Default Re: How to get a two-digit month value - 06-10-2008 , 02:31 PM



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

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



Reply With Quote
  #10  
Old   
Tom Moreau
 
Posts: n/a

Default Re: How to get a two-digit month value - 06-10-2008 , 02:31 PM



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

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



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.