Solved

SQL - Convert month name or month number to datetime

Posted on 2010-09-09
3
1,254 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how the fundamental information of how to create a table.

626 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