Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

enter mulitple dates into the same field

Posted on 2011-03-09
4
Medium Priority
?
184 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 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

715 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