Solved

Convert dateTime to Date output

Posted on 2014-01-16
3
335 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 48

Accepted Solution

by:
PortletPaul earned 500 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 48

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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.
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.

810 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