Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

enter mulitple dates into the same field

Posted on 2011-03-09
4
Medium Priority
?
185 Views
Last Modified: 2012-06-21
want to enter current date/time into a field


I think the field has to be varchar

because I may need to enter multiple dates into the same field without deleting any data that is currently in the field (append data, not update data)

maybe comma separated

and I also need to do a command to view all the dates



what is best way to do this
0
Comment
Question by:rgb192
  • 2
4 Comments
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 1000 total points
ID: 35089070

That is not a good idea to begin with. You can create a child table and enter the dates in that table.
This will better for your query performance

However to add a value to a field you could simply use an update statement
eg
  update table1
  set field1 = ISNULL(field1 + ',', '') + CAST(GETDATE() AS VARCHAR)
0
 
LVL 9

Assisted Solution

by:mayank_joshi
mayank_joshi earned 1000 total points
ID: 35091935
It is usally not recommend to use Varchar(or any other string type) for Date/DateTime fields because of the following reasons:-

    * You can't easily add / subtract days to the VARCHAR version.
    * It is harder to extract just month / year.
    * There is nothing stopping you putting non-date data in the VARCHAR column in the database.
    * The VARCHAR version is culture specific.
    * You can't easily sort the dates.
    * It is difficult to change the format if you want to later.
    * It is unconventional, which will make it harder for other developers to understand.
    * In may environments, VARCHAR will use more storage space. This may not matter for small    amounts of data, but in commercial environments with millions of rows of data this might well make a big difference.
     * No chance of getting non parsable date time data.

0
 
LVL 9

Expert Comment

by:mayank_joshi
ID: 35091959
sorry the last point is already covered in point no 3.
0
 

Author Closing Comment

by:rgb192
ID: 35097242
thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Screencast - Getting to Know the Pipeline
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question