473,809 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

get todays date and a certain time

Hi Everyone,

I am trying to write something to give me back all the data for a
sertain time range for today.
So for example: I need to get all records where change_date is <= today
2pm and today at 8pm.
I know i can get just the date for today by using
CONVERT(CHAR(10 ),getdate(),102 ) but can i add a time range to that?

Thanks in advance,
Anna

Sep 27 '06 #1
2 10451
You can use DATEADD, for example:

SELECT DATEADD(hour,14 ,CONVERT(CHAR(1 0),getdate(),10 2))

Razvan

AK********@gmai l.com wrote:
Hi Everyone,

I am trying to write something to give me back all the data for a
sertain time range for today.
So for example: I need to get all records where change_date is <= today
2pm and today at 8pm.
I know i can get just the date for today by using
CONVERT(CHAR(10 ),getdate(),102 ) but can i add a time range to that?

Thanks in advance,
Anna
Sep 28 '06 #2
On 27 Sep 2006 11:36:59 -0700, AK********@gmai l.com wrote:
>Hi Everyone,

I am trying to write something to give me back all the data for a
sertain time range for today.
So for example: I need to get all records where change_date is <= today
2pm and today at 8pm.
I know i can get just the date for today by using
CONVERT(CHAR(1 0),getdate(),10 2) but can i add a time range to that?
Hi Anna,

Use either

CONVERT(datetim e, CONVERT(CHAR(10 ), getdate(), 126) + 'T14:00:00')

or

DATEADD(day, DATEDIFF(day, 0, getdate()), '14:00:00')

to get current date with a time of 2PM.

--
Hugo Kornelis, SQL Server MVP
Sep 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2670
by: Gerry Viator | last post by:
Hi all, I have a textbox were a time is typed in like: upto 4 numbers 1900 300 1000 1425 I would like as they type the text to show todays date plus the time they
1
1756
by: garyusenet | last post by:
Using VB Express and SQL. I have an sql database. what function gives me todays date and time? and do i enter it in the 'default' property for the column in the database? i've tried now() date() date$()
2
38429
by: Chuck | last post by:
Using a macro to output a query to an Excel file. Is there a way to automatically add todays date in the file spec? As: C:\Access Data\ & todays date.xls Chuck ....
5
11988
by: Vayse | last post by:
In VB6, I would have used Date() That no longer works. How do I find todays date in VB.net?
2
3921
by: Drum2001 | last post by:
Hello, I am having isues with the following: I have two forms, a MAIN FORM with a SUB FORM: Within the MAIN FORM, I have an unbound textbox (Date Format) and a command button. Onload, the textbox defualts to Date(). The SUB FORM has a bound textbox (Date Format). I am trying to create the code for the command button to compare the
1
1461
by: Mark12345 | last post by:
Hi all before I begin to tell you my problems just a big thanks to Mary McCarthy who helped me lots. Thank You Mary!!! Right todays problems are Getting the date in my form automatically. (read below) I need to have a butt thatprint an invoice. (see below) When running a Report the Company name is duplicated on every line of the order details. I need to have my /cmpanyname/address/Tel/Order Number/ Item description by line/Qty/Line...
1
1586
by: Becki | last post by:
hi, i need to make a calculation that calculates the current length of stay for people in a hotel. so i need to take todays date from the day they booked in, any ideas? xxx
8
2432
by: Trev | last post by:
Hi Can anyone point me in the right direction here, I would like to open a table in access 2003 by date. I have an asp web page which needs to read data from a table with each days today's date (which ever day that is) then a new table is created with today's date. Example: I have a table called 17-may-2007 my ASP page reads this table for 24hours then tomorrow (12:00 midnight 18th) I will have a new table called 18-may-2007 and the...
3
4297
by: jonosborne | last post by:
Hi guys, im a bit of a novice being thrown in at the deep end ! Using MS Access 97 i have a table with data that is updated once a day from an Excel spreadsheet. I need a way of identifying when data was added to this table so i have added an extra field (titled 'Date') and need to create a query that updates the empty field with todays date, so that every day this query will run and replaces any empty data in the field with todays date. ...
0
9603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10640
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10387
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7662
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.