Solved

Problem Converting Smalldatetime to mm/dd/yy in SQL

Posted on 2004-04-22
1
692 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
listing SQL login names of valid databases 2 20
SQL, add where clause 5 23
HTML <font style="color:red"> 9 31
sql 2016 data tools breakdown.. 1 13
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

856 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