Solved

Problem Converting Smalldatetime to mm/dd/yy in SQL

Posted on 2004-04-22
1
694 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Display Date and Time 7 47
Please explain the difference between EXCLUDE, INTERSECT and JOIN 7 48
HIghlights of SSIS? 3 40
TDE for SQL Web Edition 1 29
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

738 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