Questions tagged [sysdatetime]

14 questions
5
votes
1 answer

Accuracy of SYSDATETIME Data Type in SQL Server

I have done some testing using the SYSDATETIME in stored procedure in SQL Server 2008. I have setup a table with a datetime2(7) with a IDENTITY field. I understand the difference between the precision and the accuracy of this data type however, I…
League
  • 113
  • 1
  • 8
5
votes
2 answers

Does SYSDATETIME() cost more than GETDATE()?

Is there any reason why I should stop using SYSDATETIME() everytime, instead of GETDATE() ? Don't they both ask the cpu what time it is or does sysdatetime need more instructions to calculate the fractions? Does Getdate work on rounding it? Can…
Uğur Gümüşhan
  • 2,455
  • 4
  • 34
  • 62
2
votes
1 answer

SYSDATETIME going backwards

First up, I have solved the actual problem that I had, by moving to using a datetime2, and DATEDIFFing at the MICROSECOND scale. But I'm still surprised by the behaviour I was seeing, so .... I'm trying to diagnose a perf issue with some SQL, and I…
Brondahl
  • 7,402
  • 5
  • 45
  • 74
2
votes
2 answers

Date in SELECT statement is always the same

I'm trying to insert data from one table into a table that has a two-column key. The source table does not share the destination's keys. Both key columns in the destination are varchars. I have an insert statement: INSERT INTO Table1 (Invoice,…
ZethMatthews
  • 80
  • 1
  • 8
2
votes
2 answers

using SYSTEMTIME to change Date and Time in 24 mode

I use SYSTEMTIME struct to change my system datetime like follows: [DllImport("kernel32.dll")] public extern static uint SetSystemTime(ref SYSTEMTIME lpSystemTime); private void button1_Click(object sender, EventArgs e) { SYSTEMTIME st =…
Abdullah Zaid
  • 171
  • 3
  • 9
1
vote
1 answer

Save dataframe in a folder which has sys.date

How can I save a file in a specific folder which has Sys.date()? write.csv(dummy_opp, file = "//ant/dept-as/XYZ2-User/Mega_data/File Management/SOA/Assignment-(***This folder is appended by sys.date***)"Workbook.csv",row.names = FALSE)
0
votes
1 answer

SQL function SYSDATETIME() can return duplicated values?

I have a webApi which registers orders, using a stored procedure, assigning the creation date = SYSDATETIME(). Every request registers one unique order. The problem is than two different requests to my Api, in the same second, separated less than…
Juanma R.
  • 281
  • 1
  • 3
  • 7
0
votes
3 answers

How to get transactions between yesterday and today in SQL Server 2014?

I am trying to pull up a count of all transactions that happened yesterday per hour. I don't want transactions made today. But I can't seem to get the code right in the condition. My code so far: SELECT CAST(TransDT as DATE) as 'TransDate' …
user1777929
  • 777
  • 1
  • 10
  • 28
0
votes
3 answers

How to Check Valid Date Time from Sql Table

I want to check either my current DateTime is between two DateTimes or not. I have first time 2016-05-19 04:23:00.000 and second time 2016-05-19 04:50:00.000. How to write a query to return true if current DateTime is between first and second time…
0
votes
1 answer

Getting Error with Date Format in To_Char

I am getting error in the second script. Please explain why i am getting error in the second script. select count(*) from LCL_SHR_IncidentIntegrationInt where externalsystem = 'IPSOFT' and…
Subbu
  • 41
  • 1
  • 8
0
votes
1 answer

View in SQL server 2012 with datetime function

What happens if use SYSUTCDATETIME() in a view? Will the view work correctly? When will it execute the SYSUTCDATETIME function? For instance I ve created a view from the following select SELECT * FROM dbo.contracts WHERE (contract_start <…
Nuri Tasdemir
  • 9,720
  • 3
  • 42
  • 67
0
votes
2 answers

Get previous month range using SYSDATE()

I am trying to use sysdate() to pull data for the previous month.
Carol
  • 11
  • 3
0
votes
1 answer

sql query to get data greater than everyday at particular time

I want all records which exist than particular date timestamp and the table create_datetime column. When this query is run, it should provide all the records for the day greater than create_datetime with a particular 18:00:00
Dev_Off
  • 55
  • 1
  • 9
0
votes
3 answers

Why Datediff between GETDATE() and SYSDATETIME() in milliseconds is always different?

I am trying to get Datediff between GETDATE() and SYSDATETIME() in milliseconds. SELECT DATEDIFF(ms, GETDATE() , SYSDATETIME()); The result I am getting is 0 or 1 or 2 or 3. What is the reason for this difference? See this fiddle.
Himanshu
  • 31,810
  • 31
  • 111
  • 133