Solved

SQL - Convert month name or month number to datetime

Posted on 2010-09-09
3
1,244 Views
Last Modified: 2012-05-10
Is there a way to convert a month name or month number to datetime in SQL?

Ex:
   Convert 'November' to '2010-11-01 00:00:00.000'       or
   Convert '11' to '2010-11-01 00:00:00.000'
0
Comment
Question by:Rick
  • 2
3 Comments
 
LVL 13

Author Comment

by:Rick
ID: 33637920
... or Convert 'NOV' to '2010-11-01 00:00:00.000'  
0
 
LVL 41

Accepted Solution

by:
ralmada earned 500 total points
ID: 33637959
just add the remaining part and convert to datetime
convert(datetime, '2010-' + 'NOV' + '-01')
0
 
LVL 13

Author Closing Comment

by:Rick
ID: 33638003
Simple as that!

Thank you, ralmada.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
find SQL job run average duration 24 54
SQL to JSON 14 32
SQL Syntax 6 38
Checking for column changes SQL 2014 4 18
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question