Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

Update record in SQL Table

Hello Experts,

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

TimeStamp

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,..


Thanks.
0
ASPDEV
Asked:
ASPDEV
  • 2
1 Solution
 
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
Hi,

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)

Thanks
0
 
ASPDEVAuthor Commented:
IJZ,

Thanks for the Awesome post!.
0
 
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
You are most Welcome
0
 
8080_DiverCommented:
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. ;-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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