Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Convert dateTime to Date output

Posted on 2014-01-16
3
Medium Priority
?
344 Views
Last Modified: 2014-01-16
I have a field in a datetime format.  When I do an insert into an existing table with a date field, I want the format to be 'MM/DD/YYYY'

I have the following statement:

convert(date,LastBilledDateTime,101) as LBDT.

When I look at the output the format is YYYY-MM-DD.

How can force it be MM-DD-YYYY?  The LastBilledDateTime is stored as DateTime.

Thanks

Glen
0
Comment
Question by:GPSPOW
  • 2
3 Comments
 
LVL 49

Accepted Solution

by:
PortletPaul earned 1500 total points
ID: 39787332
A datetime field does NOT store information "in a format". Datetime information is stored as numbers to minimize storage and easily facilitate date arithmetic.

It is a human need to see date in a specific format (and this is affected by culture you want MM/DD/YYYY whereas I would much prefer DD/MM/YYYY).
0
 

Author Closing Comment

by:GPSPOW
ID: 39787338
I see that now.  

Thanks

glen
0
 
LVL 49

Expert Comment

by:PortletPaul
ID: 39787411
no problem, you might find this page by Tibor Karaszi useful:

"The ultimate guide to the datetime datatypes"
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

772 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