Click here to Skip to main content
12,404,478 members (70,774 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL
Hello, I have created a table with name and date. Their respective data types are varchar and datetime.

If I insert date in web page, I am getting time also i.e., if I insert 11/11/2012 in web page, in sql table, I am getting its record as 11/11/2012 12:00:00.

I need to get that record as only date but not date time in sql table, How can I do this??

Thanks. .
Posted 22-Nov-12 2:27am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

your column description either chose only "date" type

otherwise use Convert(varchar,mydateColumn, XYZ)as mydateColumn

replace xyz with a number between 100 to 125
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Change your table definition as in for date, use data type only "date" instead of "datetime"..
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

You can format the date in your query

SELECT convert(varchar, getdate(), 103) --date in dd/mm/yyyy format

Refer this link[^] for different date formats in sql.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

hi,

use below,

when you retrieve data from table that time use below format for retrieval:
CONVERT(VARCHAR(8),GETDATE(),101) AS DateOnly

this will help you..




happy coding..
  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
Web01 | 2.8.160721.1 | Last Updated 22 Nov 2012
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