Solved

SQL - Convert month name or month number to datetime

Posted on 2010-09-09
3
1,206 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
Comment Utility
... or Convert 'NOV' to '2010-11-01 00:00:00.000'  
0
 
LVL 41

Accepted Solution

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

Author Closing Comment

by:Rick
Comment Utility
Simple as that!

Thank you, ralmada.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now