Link to home
Start Free TrialLog in
Avatar of chokka
chokkaFlag for United States of America

asked on

SQL one day before ( Yesterday ) from Current date

Below syntax allows me to get a day prior

SELECT dateadd(day,datediff(day,1,GETDATE()),0)

Open in new window


When I implement in my where condition for my Table - Date

It doesn't return exact date.

This is how my actual date in the database looks like

2015-03-19 00:00:00.000

I need to implement in the where condition
ASKER CERTIFIED SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is how my actual date in the database looks like

2015-03-19 00:00:00.000

Please note that is simply does NOT matter what a date/time value "looks like". Internally the database is actually storing that information as integers. What you see is a "style" (or "format") that as the default output for that type of data.

In other words, you can alter the presentation style of a date to 19/03/2015 or 03/19/2015 but they are all the same date

for more see:
The ultimate guide to the datetime datatypes
https://www.experts-exchange.com/articles/12315/SQL-Server-Date-Styles-formats-using-CONVERT.html
Avatar of chokka

ASKER

Thanks