Solved

enter mulitple dates into the same field

Posted on 2011-03-09
4
182 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Format Date fields 11 65
Using this function 4 54
How can I find this data? 3 41
What Is an Error? 2 59
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…
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 …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

710 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