Click here to Skip to main content
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 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...
  Permalink  
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 Dnyaneshwar@Pune 1,300
1 Sergey Alexandrovich Kryukov 670
2 OriginalGriff 319
3 Tadit Dash 310
4 ravikhoda 300
0 Sergey Alexandrovich Kryukov 11,224
1 OriginalGriff 6,897
2 Peter Leow 4,795
3 Abhinav S 3,838
4 Maciej Los 3,575


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