Click here to Skip to main content
15,896,013 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How to store 3 different dates in single column of a table in a database? pls help me
Posted

Concatenate[^] multiple dates(in string) into single string (separate them using comma) like,
C#
string date1 = "1-1-2001";
string date2 = "2-2-2002";
string date3 = "3-3-2003";

string newDate = date1 + ", " + date2 + ", " + date3;

string query = "INSERT INTO TABLE_NAME (COLUMN_NAME) VALUES(newDate)";
// and rest of the stuff...


-KR
 
Share this answer
 
firstly you have to declare the field as varchar / varchar2. so that it can take up the long string.
now concate the date values and then store this concatenated value in the database.
 
Share this answer
 
If you save your data like that, it breaks the first CODDS NF Rule, that is you will be storing multiple values which is never a good thing. Check this:

http://en.wikipedia.org/wiki/Database_normalization[^]

Decompose the dates maybe like Date1, Date2, Date3, since you are already sure there are 3 date. Then add them like usual like this:

http://www.entityframeworktutorial.net/EntityFramework4.3/Introduction.aspx[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900