Dates dates dates dates... SQL and ASP.NET

D

David Lozzi

Howdy,

Users can specify a date in a field labeled dtDate. This field in SQL is a
smalldatetime. When I vew the raw data in the table, it displays 9/29/2008,
and when a user doesn't specify a date it displays as 1/1/1900.

Issue 1) When displaying the records in a datagrid, using basically all
default configs for the datagrid, and a stored proc to query the table, the
dates appear as such: 9/29/2005 12:00:00 AM and 1/1/1900 12:00:00 AM. WHY?!
Why doesn't it display the data thats in the table which is ONLY the date?

Issue 2) What's the best way to deal with the 1/1/1900 date default?

I'm writing a calendar console so if I have to format each date field
everytime I use it, I may go crazy. I would think that this is either a slip
in my script or my workstation is not performing correctly....

Thanks for your help!!
 
R

Rob Schieber

David said:
Howdy,

Users can specify a date in a field labeled dtDate. This field in SQL is a
smalldatetime. When I vew the raw data in the table, it displays 9/29/2008,
and when a user doesn't specify a date it displays as 1/1/1900.

Issue 1) When displaying the records in a datagrid, using basically all
default configs for the datagrid, and a stored proc to query the table, the
dates appear as such: 9/29/2005 12:00:00 AM and 1/1/1900 12:00:00 AM. WHY?!
Why doesn't it display the data thats in the table which is ONLY the date?

You need to tell your application how to format the strings: see
http://msdn.microsoft.com/library/d...e/html/cpconstandarddatetimeformatstrings.asp

Issue 2) What's the best way to deal with the 1/1/1900 date default?

I think this is an input validation issue, make sure users enter a date,
or find some way to handle the display of null or default dates. Bottom
line, you need to provide the logic for this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

dates 0
Dates, time zones,daylight saving time 1
Handling Dates.... 2
Cultures & dates 2
dates sql and aspc.... 1
Hibernate, mySQL and formatting dates 3
Graph Dates and Values 4
calculating an array of dates 4

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top