Solved

Convert 'short date' to 'long date'

Posted on 2008-10-09
4
1,034 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 500 total points
ID: 22681947
you may have to add a specific day such as '01' to it, or change the table schema
0
 
LVL 59

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 59

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

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

11 Experts available now in Live!

Get 1:1 Help Now