Solved

Convert 'short date' to 'long date'

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

763 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