Solved

Convert 'short date' to 'long date'

Posted on 2008-10-09
4
1,035 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

910 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

22 Experts available now in Live!

Get 1:1 Help Now