Questions tagged [getdate]

getdate is a T-SQL function available to retrieve the current system date and time.

getdate() is a function that returns the current system date and time in a datetime format in RDBMSs that use T-SQL. It is available for use in MS SQL Server, SAP/Sybase Adaptive Server Anywhere, SAP/Sybase SQL Anywhere and SAP/Sybase IQ.

412 questions
2
votes
3 answers

SSIS take -1 hour from current date and time

I am new at SSIS currently trying to do is to get 1 hr less from current time I am using (DT_DATE) GETDATE() My Output is: 27/02/2017 4:24:09 PM My Expected output is: 27/02/2017 3:24:09 PM Can please someone help me on this. Thanks
YJG
  • 123
  • 2
  • 12
2
votes
1 answer

SQL Query - Dynamic Month Change based on Current Date

I have this table in SQL. [Tbl_SALES] +-------------+-----------+-------------+---------+-------+------+-------+ | Cust_Number |Code_Number| PartNumber | UserID | Month | Year | Sales…
Luis Lara
  • 75
  • 2
  • 9
2
votes
2 answers

SQL Working Days between two Dates

Hi I have the following function to work out WD between two dates. my query is...i have two dates with the same date eg. 06/07/2016 and i want WD to show as 0 but instead it is showing as 1. is there away to change how WD is worked out? ALTER…
sql2015
  • 591
  • 3
  • 13
  • 34
2
votes
1 answer

SQL Server 2008 R2: getdate() returns wrong date

We have a table which has a InsertDate column that gets its value by calling the getdate() function. But there are some records that have weird values like: 3879-07-08 11:25:43.947 4500-09-29 11:25:43.983 3258-03-20 16:33:52.493 Although these…
user3577606
  • 137
  • 1
  • 10
2
votes
3 answers

Redshift: Running query using GETDATE() at specified list of times

So, I have a query that uses GETDATE() in WHERE and HAVING clauses: SELECT GETDATE(), COUNT(*) FROM ( SELECT 1 FROM events WHERE (event_time > (GETDATE() - interval '25 hours')) GROUP BY id HAVING MAX(event_time) BETWEEN (GETDATE() -…
shashwat
  • 992
  • 1
  • 13
  • 27
2
votes
2 answers

How can I get last week date starting monday to sunday in javascript

I want a javascript function that gives me start_date as the last week monday date and end_date as last week sunday date. So for example, today is 03/09/2016, so I want start_date = 02/29/2016 end_date = 03/06/2016 so far I have wriiten the code…
Krystal
  • 73
  • 2
  • 8
2
votes
4 answers

SQL query to select range from specific date/time yesterday to specific date/time current day

SELECT * FROM services WHERE service_date BETWEEN (dateadd(DD, -1, getdate())) AND (dateadd(DD, 1, getdate())) **---Gives us a last one day data.** but what we really need is data from 07:00 AM yesterday to 06:59 AM current day, so I tried the…
Altimo
  • 51
  • 3
2
votes
2 answers

How to use DATEPART of the GETDATE as a variable for a query

This might be easier than I'm making it, I'm pretty new to SQL. I have a database with a lot of movies release dates in the format YYYY-MM-DD. I'm trying to write a query that would return films released on the current date (MM-DD) in various…
SonOfJorEl
  • 23
  • 2
2
votes
2 answers

SQL Date Range from current year

I need to make a function in SQL on SSMS to get sums of columns pertaining to a certain date range (From 9-1 of a year until 8-31 of the next year). the issue is that each year this date range will change. I know how to code in SQL: Create View…
Davidp04
  • 145
  • 1
  • 7
  • 17
2
votes
1 answer

Compare difference between GETDATE() and Datetime2 in SQL Server

I want to check the amount of hours difference there is between current time (GETDATE()) and StartTime. This is what I have so far: SELECT CheckedOut, GETDATE() AS CurrentDateTime, StartTime FROM TimeRecordModels WHERE CheckedOut =…
Purrx
  • 63
  • 1
  • 7
2
votes
4 answers

sql job and datetime parameter

Another developer created a stored procedure that is set up to run as a sql job each month. It takes one parameter of datetime. When I try to invoke it in the job or in just a query window I get an error Incorrect syntax near ')'. The call to…
geoff swartz
  • 5,437
  • 11
  • 51
  • 75
2
votes
1 answer

Get start and end date of current week in Sybase

I am trying to get the Start and End dates of the current week for a table in my Sybase ASE database, and return those dates as variables I can add into an insert call. Ideally, the function can work simply based on the getDate() function. I have…
jFram
  • 73
  • 3
  • 14
2
votes
1 answer

How to use GETDATE() in Oracle to find number of days between Current Date and some specified date?

Suppose I have a table called projects and it has columns as projectid, startdate and enddate. The startdate of each project is specified already and the enddate is specified only for projects that are already finished. For ongoing projects, the…
ronilp
  • 455
  • 2
  • 9
  • 25
2
votes
4 answers

CASE statement with GETDATE()

Wondering if you can help a little with the syntax here. Trying to set a variable as a month value dependent upon whether it is past the 25th day of the month. If it is, then it uses the current month (e.g. the variable 'month' will be 10 if the…
CSF90
  • 111
  • 3
  • 3
  • 13
2
votes
1 answer

Does GetDate() get re-evaluated for each iteration within loop within a transaction?

I have a scenario where I am looping through a resultset within a transaction and I need to INSERT a unique datetime value within a table for each iteration through the resultset - will GetDate() be recalculated each time or will it only be…
Robert W
  • 2,921
  • 7
  • 34
  • 42