Solved

Problem Converting Smalldatetime to mm/dd/yy in SQL

Posted on 2004-04-22
1
690 Views
Last Modified: 2006-11-17
I can't seem to figure out what I am doing wrong. I have a table that contains a field in a smalldatetime format. I am trying to get sql to populate a text file. I want the smalldatetime field out of sql in the mm/dd/yy format. I am using a simple select statement. But all I get back is the standard sql date display in query analyzer. Here is the code and an example of the output.

Select
Convert(smalldatetime,Prod_Orig_Pub_Dt,1) AS Prod_Orig_Pub_Dt
FROM tbl_Product_FTP

This is what the query window displays....

2004-05-06 00:00:00
0
Comment
Question by:OHIS
1 Comment
 
LVL 14

Accepted Solution

by:
adwiseman earned 100 total points
ID: 10891208
To format a datetime field, you convert it to a VARCHAR, woth the format option in the convert function

Select
Convert(VARCHAR,Prod_Orig_Pub_Dt,1) AS Prod_Orig_Pub_Dt
FROM tbl_Product_FTP
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

863 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

21 Experts available now in Live!

Get 1:1 Help Now