Try using this:
CONVERT(VARCHAR(10), Your_Field, 103)
Main Topics
Browse All TopicsHow do i convert this date into sql server 2005 datetime format which is dd/MM/yyyy
while i am getting this date result
21:53:20 Jul 09, 2009 PDT
thank you,
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Your database system should be storing things as the datetime type. The rest is just formatting.
If you're querying the table and it's coming out as "21:53:20 Jul 09, 2009 PDT", then don't worry - let whatever's asking do the reformatting (for example a VB.Net application, SSRS report, whatever).
Handle dates as dates. Strings as strings. Don't confuse the two, and only convert a date into a string when it's time to display it.
Rob
There is no "style" code that will handle a string conversion of time + date + PDT (the PDT being time zone)
Not sure where you are getting that from... "while I am getting this date result" getting it from where ? Is it a variable ? A column in the database ? What datatype is the column ?
To cast as a datetime, this will work : select convert(datetime,replace('
Once it is a "recognised" datetime, and going into a datetime datatype, then it really doesn't matter too much about the format because SQL will manage it all for you (so long as it is a recignised datetime data type). Meaning... Your database might be showing dd/MM/yyyy, but underneath it is a datetime data type
I'm still wondering where that date format is coming from. Presumably no user is providing it in that format (complete with timezone info). Is it a User Control (in which case, the user control should have a method of providing it in a .Net DateTime type), is it another application (same applies), or something else?
The biggest problem with dates is showing them. I'm betting you don't actually have to deal with it as a string at all, and that whatever is formatting it in that way will happily give you the date as a date.
Rob
Thanks elmbrook,
Given the "real" answer, I am not so sure I deserved the points.
It would have helped had you let us know your "datasource". Being code based we might have zeroed in on the "real" problem a bit earlier. But not to worry, so long as you did arrive at a solution...
That will give you both date and time - but if just needing a date, then you could also use : DateTime.Now.Date which sets time component to zero, ie 00:00:0000
Cheers,
Mark Wills
Business Accounts
Answer for Membership
by: rrjegan17Posted on 2009-07-09 at 22:12:53ID: 24820451
This should help you out.
convert(datetime, ur_datetime_column, 103)