Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Date Format

Author  Topic 

sanjay5219
Posting Yak Master

240 Posts

Posted - 2013-08-05 : 12:50:36
Hi All,

One of report is coming as Jun 20, 2013 how can i convert this in datetime

Please suggest

MuMu88
Aged Yak Warrior

549 Posts

Posted - 2013-08-05 : 13:05:42
Try cast(date_column as DATETIME) in your select statement in Dataset
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-08-05 : 13:06:24
If your underlying data is datetime, you can format it to anything you want it to look like (via setting the format in the properties window). There are a few standard formats that you can use, listed here: http://msdn.microsoft.com/en-us/library/ms252080%28VS.80%29.aspx

If those don't give you exactly what you are looking for, you can apply custom format strings - see the list of format codes here: http://msdn.microsoft.com/en-us/library/ms252080%28VS.80%29.aspx
Go to Top of Page

MuMu88
Aged Yak Warrior

549 Posts

Posted - 2013-08-05 : 13:14:55
Or you can do this:
http://technet.microsoft.com/en-us/library/cc627538.aspx

To format a date field

1.Click the Design tab.

2.Right-click the cell with the [Date] field expression and then click Text Box Properties.

3.Click Number, and then in the Category field, select Date.

4.In the Type box, select January 31, 2000 1:30 PM.

5.Click OK.

6.Preview the report to see the change to the [Date] field and then change back to design view.

Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-08-05 : 14:17:02
Mumu, not fair! Not only did you snipe me, you are posting a better and more detailed solution. Are you trying to make me look bad?
Go to Top of Page

MuMu88
Aged Yak Warrior

549 Posts

Posted - 2013-08-05 : 15:20:17
I don't think it is possible to make you look bad
quote:
Originally posted by James K

Mumu, not fair! Not only did you snipe me, you are posting a better and more detailed solution. Are you trying to make me look bad?

Go to Top of Page
   

- Advertisement -