Solved

Problem Converting Smalldatetime to mm/dd/yy in SQL

Posted on 2004-04-22
1
689 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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
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 …
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

762 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

12 Experts available now in Live!

Get 1:1 Help Now