Solved

enter mulitple dates into the same field

Posted on 2011-03-09
4
175 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:
ewangoya earned 250 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 250 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now