Click here to Skip to main content
12,406,342 members (71,181 online)
Rate this:
 
Please Sign up or sign in to vote.
Dear Friends,

am working on Asp.Net, C#, SqlServer 2005.

I have a Table in SqlServer 2005 DataBase.

In this Table i have a column name DateValidFrom with Data Type as (Datetime) and when i run this table with Query the column displays as
2013-01-15 00:00:00.000

and When i load this database table to asp.net Gridview it is displaying same as 2013-01-15 00:00:00.000 But I dont need time Just I need like this format 2013/01/15.

Please help. thanks.
Posted 14-Jan-13 19:24pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Try the below query when selecting the data.
SELECT CONVERT(char(10), GetDate(), 111) --2013/01/15
Replace GetDate() with the Column Name.

Thanks...
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Take the Date into a DateTime property or variable and use ToShortDateString() method of datetime in your C# code OR at you can convert the date to shortdate using :-
Select Convert(VarChar, GetDate(), 101)

Thanks,
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Try formating the date as shown below
SELECT REPLACE(convert(varchar, getdate(), 102),'.','/') --2013/01/15

Refer
SQL Server Date Formats[^]
How to format datetime & date in Sql Server[^]
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160730.1 | Last Updated 15 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100