Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
cast convert problem i want the format to be in dd/MM/yyyy 04:10:02 PM

i am using right now
SQL
convert(char(29),datetime,109)

it is of format Aug 13 2013 04:10:02:000 PM
but i want in cast convert problem i want to be in dd/MM/yyyy 04:10:02 PM format i.e: 13/08/2013 04:10:02PM
Posted
Updated 13-Aug-13 6:20am
v2
Comments
Ankur\m/ 13-Aug-13 8:14am    
SQL or ASP.NET (C# / Vb.Net precisely) ?

Try this:
SQL
declare @mydate datetime = getdate()
select convert(varchar,@mydate, 103) + right(convert(varchar,@mydate,100),8)
 
Share this answer
 
v5

VB
Format(DateTime.Now, "dd/MM/yyyy hh:mm:ss tt")
'or
DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt")


C#
DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt");

 
Share this answer
 
v3
Comments
Mike Meinz 13-Aug-13 14:57pm    
Nice! I didn't know you could use the DIV tag to add tabs.
Maciej Los 13-Aug-13 16:25pm    
I know it from few months only ;)
If it is Sql try CONVERT(VARCHAR(25), GETDATE(), 131)
 
Share this answer
 
Change the times and, the date use a different link

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900