Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-06-19
5
Medium Priority
?
1,637 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 800 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 200 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 66

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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

721 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