Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2011
    Posts
    6

    Unanswered: How to get the Date and Hour in Sql Server 2005

    Hi,
    I have a Date column in my table.I want to insert the Date and hour in that Column.
    Here is the sample data 2011/11/25 11 AM
    The Text in Bold i.e 11 Am is how the hour part i want.Is it possible to do.

  2. #2
    Join Date
    Sep 2011
    Location
    Greenville, SC USA
    Posts
    34

    RE: How to get the Date and Hour in Sql Server 2005

    In SS2005, it does appear that this can be done.
    The following is a simple proof of concept for you to try:

    Code:
    declare @dt datetime;
    set @dt = '2011/11/25 11 AM';
    select @dt

  3. #3
    Join Date
    Oct 2011
    Posts
    29
    Above query not display AM/PM try this..

    SELECT
    GETDATE() AS CurrentDate,
    RIGHT(CONVERT(VARCHAR, GETDATE(), 100),7) AS CurrentTime,
    CONVERT(VARCHAR(10), GETDATE(), 101) + ' ' + RIGHT(CONVERT(VARCHAR, GETDATE(), 100),7) AS CurrentDateTime

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •