?
Solved

Convert 'short date' to 'long date'

Posted on 2008-10-09
4
Medium Priority
?
1,042 Views
Last Modified: 2012-05-05
you might think it's stupid question but I thought I would have asked anyway.  I have a table that has a field calls dateEnter was designed as DateTime type (mm/dd/yyyy hh:mm:ss) but my date comes in as varchar (short date - m/yyyy).  
Is there a way to convert a short date (mm/yyyy) to long date (datetime type) in order to write it to the database table without having to add a specific 'dd' value to it.

Thank you for your help with this.
0
Comment
Question by:BostCelt
[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
4 Comments
 
LVL 9

Accepted Solution

by:
jamesgu earned 1500 total points
ID: 22681947
you may have to add a specific day such as '01' to it, or change the table schema
0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 22681975
Don't believe you can do this without putting in a day.

Can either generate day as today OR hardcoded value for day in month you want like '01'.
DECLARE @shortdate varchar(7)
SET @shortdate = '10/2008'
 
SELECT CAST(REPLACE(@shortdate, '/', '/' + str(day(getdate())) + '/') AS datetime) AS LongDate

Open in new window

0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 22681981
@james, sorry didn't see your post.
0
 

Author Closing Comment

by:BostCelt
ID: 31504809
That is what I thought too.
0

Featured Post

AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

718 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