Solved

datetime format

Posted on 2011-09-20
11
246 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this article I will describe the Copy Database Wizard 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.
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now