Solved

enter mulitple dates into the same field

Posted on 2011-03-09
4
179 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

785 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