Update record in SQL Table

Posted on 2011-05-03
Last Modified: 2012-08-13
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,..

Question by:ASPDEV
    LVL 16

    Accepted Solution


    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)


    Author Closing Comment


    Thanks for the Awesome post!.
    LVL 16

    Expert Comment

    by:Imran Javed Zia
    You are most Welcome
    LVL 22

    Expert Comment

    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. ;-)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
    Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now