473,413 Members | 2,066 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Converting GetDate() to current date with a specific time

I want to return the the date for the day before my query runs but at a specific time. The time is not midnight, so:

convert(varchar(19),getdate() and '08:00:00',101)

does not work. Instead I want to return the day before at 8am.

Thanks.
Aug 29 '07 #1
2 10910
azimmer
200 Expert 100+
I want to return the the date for the day before my query runs but at a specific time. The time is not midnight, so:

convert(varchar(19),getdate() and '08:00:00',101)

does not work. Instead I want to return the day before at 8am.

Thanks.
Expand|Select|Wrap|Line Numbers
  1. convert(datetime,left(convert(varchar, getdate(), 121),4+1+2+1+2) + ' 08:00')
  2.  
Aug 30 '07 #2
Expand|Select|Wrap|Line Numbers
  1. (dateadd(hour,8(dateadd(day,-1,convert(datetime,convert(date,getdate()),102)))))
Dec 28 '17 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Spare Brain | last post by:
Hi, I am observing a strange error with the time portion of the java.sql.Date() when using resultSet.getDate() - it always seems to show 12:00:00. The following code prints 2004-10-27...
2
by: Konstantin Zakharenko | last post by:
Hello, Our QA team have running a lot of test scripts (for automated regression testing), they run them on the different databases (Oracle/MS SQL). Several of those tests are dependent on the...
3
by: Yann Laviolette | last post by:
Hi! I look for a function like the Windows function getdate(&d); and gettime(&t); to have the date and the time. Also I look for a function like spawnl to call another program. These function...
6
by: marc | last post by:
hi im trying to convert Date() into a unix timestamp so i can stick the result into a mysql db, please help!
6
by: Matik | last post by:
Hi, I have a funny situation. Within: MSSQL 2000 SP3, everything below described is running on same PC. there is a program running, which sends information to two other programs. This...
6
by: FFMG | last post by:
Hi, My timezone is GMT +2 So when I do a $date = getdate( 0 ); I get: $date = {
3
by: Yas | last post by:
Hi, I am creating creating a table with a Date column dd-mm-yyyy. But I cant seem to find a SQL function that just returns today's date. getDate() returns the time as well so I cant use it. ...
1
by: napjohn8 | last post by:
here is my question with getdate function --12. List the names and staff number for staff who manage detached properties that have a current lease i.e. there is a lease and its end date is in the...
7
by: Bassem | last post by:
I'm trying to select all records inserted in a certain day, so comparing date only and ignore the time. I searched for a function but didn't found. I found this: WHERE day() = day(GetDate()) AND...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.