Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Convert 'short date' to 'long date'

Posted on 2008-10-09
4
Medium Priority
?
1,043 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
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

877 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