Tag: datetime

Adding a month to a date in T SQL

How can I add one month to a date that I am checking under the where clause? e.g.: select * from Reference where reference_dt + 1 month

how to get the 30 days before date from Todays Date

How do you get the 30 days before today in SQL.

DateTimeOffset.Now in T-SQL

I’m executing a INSERT to a sql 2008 db. How do I specify in T-SQL to insert NOW in a DATETIMEOFFSET column? GETDATE()?

Convert a SQL Server datetime to a shorter date format

I have a datetime column in SQL Server that gives me data like this 10/27/2010 12:57:49 pm and I want to query this column but just have SQL Server return the day month and year – eg. 2010 10 27 or something like that. What are the functions I should be researching? Should I be […]

What is the meaning of the following SQL Server declaration: datetime2(7)?

Inside a SQL Server query, there is: datetime2(7). I know datetime2, but I don’t understand (7). Can you explain the meaning of (7)?

How to get DATE from DATETIME Column in SQL?

This question already has an answer here: How to return the date part only from a SQL Server datetime datatype 35 answers

Delete items older than a day – SQL Server

In a table in my datatase I have a datatime column which stores the time at which the record is added. How can I delete all records which are older than a day when I run a stored procedure (considering the current time) ?

Dividing a value by number of days in a month in a date field in SQL table

I am working on an SQL query which performs some arithmetic division on the data in a SQL Table based on the value in a date column. To elaborate I have the following SQL table Deals id Date Type Quantity Price 3 2014-11-04 Sweet 2500 23 9 2014-12-04 Sweet 5000 30 10 2014-12-04 Midale 2500 […]

How to display Date in DD/MM/YYYY H:MM AM/PM format in SQL Server

I have a DATETIME Column in a table and I need to show the date in the following format “DD/MM/YYYY H:MM AM/PM” CreatedBy 2013-07-30 12:44:06.000 2013-07-30 12:45:57.000 2013-08-05 16:51:26.000 2013-08-05 19:08:18.000 2013-08-05 19:11:46.000 2013-09-12 12:44:27.000 I need the date like this–> “30/07/2013 12.44 PM”

How to test two datetimes for equality in T-SQL (ignoring their time components)?

How can I test two datetimes (not including their time components) for equality?

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.