• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 196
  • Last Modified:

Update record in SQL Table

Hello Experts,

I need to update a Time field in a table its is nvarchar field.


ID   date                    Time
--  ------                      -----
1    01/01/2011         10:00
2    01/01/2011         10:57
3    01/01/2011         11:30

All the fields in the Timestamp table are Nvarchar, I need to update Time field with PLUS 1. For instance in the time field I have a string data "10:00" , need to update( +1) . It should be 11:00. And rest of them too 11:57, 12:30,..

  • 2
1 Solution
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:

you can use following in update queries as per requirement, just change getdate() with related parameter

select cast(datename(hour, getdate())+1 as nvarchar) + ':'  + cast(datename(minute, getdate()) as nvarchar)

ASPDEVAuthor Commented:

Thanks for the Awesome post!.
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
You are most Welcome
As a passing observation, storing dates and/or times as characters instead of actual date or time datatypes opens up your database to the possibility of having to deal with invalid dates and/or times.  There is a reaseon that Date, Time, and DateTime datatypes exist, just as there is a reason that the INTEGER datatype exists. ;-)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now