SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Date Format
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sanjay5219
Posting Yak Master

218 Posts

Posted - 08/05/2013 :  12:50:36  Show Profile  Reply with Quote
Hi All,

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

Please suggest

MuMu88
Aged Yak Warrior

547 Posts

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

James K
Flowing Fount of Yak Knowledge

3557 Posts

Posted - 08/05/2013 :  13:06:24  Show Profile  Reply with Quote
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

547 Posts

Posted - 08/05/2013 :  13:14:55  Show Profile  Reply with Quote
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.


Edited by - MuMu88 on 08/05/2013 13:15:38
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3557 Posts

Posted - 08/05/2013 :  14:17:02  Show Profile  Reply with Quote
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

547 Posts

Posted - 08/05/2013 :  15:20:17  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000