Solved

Data formatting:  GETDATE() - 1 day, with time 00:00:00.000

Posted on 2008-06-19
5
1,633 Views
Last Modified: 2008-06-19
I need a function build that returns whatever yesterday was, with the timestamp of 00:00:00.000

i.e. Set @variable =  CONVERT(datetime, getdate(), 101), with time 00:00:00.000 instead of 15:25:55:042

TIA
Jim
0
Comment
Question by:Jim Horn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 200 total points
ID: 21825989
select cast(convert(varchar(10), dateadd(d, -1, getdate()), 101) as datetime)
0
 
LVL 31

Assisted Solution

by:James Murrell
James Murrell earned 50 total points
ID: 21825995
0
 
LVL 3

Expert Comment

by:darkmooink
ID: 21825997
CONVERT(datetime, month(getdate()) + day(getdate()) + year(getdate()), 101)
i think this might work
0
 
LVL 65

Author Comment

by:Jim Horn
ID: 21826041
>select cast(convert(varchar(10), dateadd(d, -1, getdate()), 101) as datetime)
Worked.

>http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=64759
This could come in handy.

>CONVERT(datetime, month(getdate()) + day(getdate()) + year(getdate()), 101)
returned 1905-07-27 00:00:00.000
0
 
LVL 3

Expert Comment

by:darkmooink
ID: 21826101
doh sorry
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

734 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