Solved

datetime format

Posted on 2011-09-20
11
266 Views
Last Modified: 2012-05-12
convert(varchar, dateSubmitted, 110) as dateSubmitted just gives me date a 08/15/2011 format and I want to also see time beside the date how to do that.. tsql
0
Comment
Question by:1jaws
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 36569902
If you want to see the date and time, then why use the CONVERT function at all?
0
 
LVL 18

Expert Comment

by:lludden
ID: 36569957
You can use CONVERT(varchar(20),DateSubmitted,0).  Look at the table in BOL to see what all the convert options do.
0
 

Author Comment

by:1jaws
ID: 36570337
I need to use such as 08/15/2011 on the date part.. shows me Aug 15 2011
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 18

Expert Comment

by:lludden
ID: 36570458
Then you need to combine two:

SELECT convert(varchar(8),DateSubmitted,101) + ' ' + convert(varchar(5),DateSubmitted,108)
0
 

Author Comment

by:1jaws
ID: 36570483
still not right... it shows me as 08/15/20
0
 
LVL 18

Assisted Solution

by:lludden
lludden earned 250 total points
ID: 36570514
Because I can't count.

SELECT convert(varchar(10),DateSubmitted,101) + ' ' + convert(varchar(5),DateSubmitted,108)
0
 

Author Comment

by:1jaws
ID: 36570529
still need a see AM, PM also :)
0
 
LVL 32

Accepted Solution

by:
ewangoya earned 250 total points
ID: 36570728

select CONVERT(varchar(10), dateSubmitted, 101) + ' ' +
       RIGHT(CONVERT(varchar, dateSubmitted, 100), 8)
0
 

Author Comment

by:1jaws
ID: 36570741
thank you ewangoya! it works.. Ok, how should I give points now? :)
0
 
LVL 32

Expert Comment

by:ewangoya
ID: 36570748

At your discretion, you can split or award all points according to the relevance and correctness of the solution
0
 

Author Closing Comment

by:1jaws
ID: 36570750
Thanks Guys!
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

778 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