Wrox Programmer Forums
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 8th, 2008, 02:24 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default Storing date in dd/mm/yyy format

Hi

I am storing date in the dd/mm/yyyy format into the SQL Server database, but while I do a search on dates, I am not getting proper results, I mean when the date is say 05/05/2008, these rows are ommitted. Can anyone help on how to store and fetch dates in the dd/mm/yyy format...

Regards
Mike
__________________
Regards
Mike
 
Old May 13th, 2008, 04:23 AM
Authorized User
 
Join Date: Sep 2007
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Don't format datetime values when you are storing them. Just store them in DateTime datatype and be happy about it. Things get a lot easier. You don't need to do any tedious casting/formatting when comparing values. You can simply say "SELECT * FROM MyTable WHERE MyTimeStamp > @startDate AND MyTimeStamp < @endDate" for example.

When displaying the data to user do your formatting stuff there. Something like DateTime.ToString("dd/MM/yyy") or whatever.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Display date as mm-dd-yy (without century) elygp ASP.NET 1.0 and 1.1 Professional 1 May 9th, 2007 03:21 AM
Date dd-mm-yyyy John2112 SQL Server 2000 2 March 16th, 2007 05:15 AM
Convert date String (dd/mm/yy) to dd- Month- yy minhpx J2EE 2 March 6th, 2007 08:29 AM
Converting date to yy.mm.dd format using CONVERT Jinn SQL Server 2000 6 October 14th, 2006 06:44 PM
Date formats... dd/mm/yyyy SeanW Classic ASP Databases 3 June 14th, 2004 12:34 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.