Hi,
I let say I use this code to retrieve date from database

SELECT Table.Date FROM Table

The format is 01/09/2013 (dd/mm/yyyy)

How will i format this to get 09-Jan-2013 output then print this format to crystal report?
I'm using dataset to connect data to crytal report
I just noticed if im not mistaken that even I format the date to different format, the date in crystal report is not changing.

Thanks in advance

Incase anyone needs it here is how the above can be done:

string.Format("{0:dd/MMMM/YYYY}", Convert.ToDateTime(reader["Date"]).ToLongDateString());

I dont know if this works or some kind of ms code but i did it bby converting the nvarchar to date then convert it again to varchar before making some formatting. i dont know why but formatting for me doesn't work with nvarchar datatypes.

Sorry I must have missread your first post. My reply above is a solution if you want to convert a dat formatted as "dd/mm/yyyy 00:00:00" this has been loaded from an SQL database, to dd/mm/yyyy format in C#.

Could you post your solution so I can have a look at how you did it please? Also it would help other people with the same issue.

Sorry for the late rep, here's what did

CONVERT(varchar(MAX), CAST([Table].[Date1] AS Date), 107) AS Date

Hope it helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.