|
-
Sep 14th, 2006, 09:26 AM
#1
Thread Starter
Lively Member
Determining the format of a date
Hi
I have a date value that is being brought back from a database that I want to put into a datetimepicker on my form. Unfortunately some of the existing data is rather messy and some dates have only been put in as the year. This means that I get an error when trying to put something like 2003 into a datetime picker that is expecting a ddmmyyyy format.
Is there any way that I can either check if the data is in the ddmmyyyy format or could I convert it to that format for populating the datetimepicker?
Thanks.
-
Sep 14th, 2006, 04:51 PM
#2
Re: Determining the format of a date
What kind of database are you working with? The column in your database should be of a date type to prevent this. You could check the length of the value to determine if only a year was retreived. You could also use the date.parseexact method, and handle the exception if an invalid date was retreived.
-
Sep 15th, 2006, 03:13 AM
#3
Thread Starter
Lively Member
Re: Determining the format of a date
It's a SQL Server DB. The original application was done in access and is not the best design ever and a lot of the data is quite messy. At the moment it's just been pulled over the SQL Server, with no changes made. The field I'm looking at is an nvarchar rather than a date so i guess maybe I should do some cleaning up of the DB itself. I'll try out your suggestions tho, thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|