Click here to Skip to main content
11,415,025 members (67,226 online)
Rate this: bad
good
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 20: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
0 Sergey Alexandrovich Kryukov 9,160
1 OriginalGriff 7,487
2 Maciej Los 3,710
3 Abhinav S 3,298
4 Peter Leow 3,084


Advertise | Privacy | Mobile
Web01 | 2.8.150427.4 | Last Updated 15 Jan 2013
Copyright © CodeProject, 1999-2015
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